Skip to content

基于Huploadify(基于uploadify)的图片上传插件,自动上传,上传进度条,上传后预览

Notifications You must be signed in to change notification settings

heroes7/HHuploadify

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HHuploadify

HHuploadify is a plugin to help deverloper to build a image uploader quickly. It's based on Huploadify which is based on uploadify. But it's different from the other two :

Install

Based on jquery, append the scripts to html .

<link rel="stylesheet" href="HHuploadify.css">
<script src="jquery.min.js"></script>
<script src="HHuploadify.js"></script>

When you want to use ready helpers :

<script src="dragsort.min.js"></script>
<script src="HHuploadifyReady.js"></script>

dragsort is a jquery plugin which help you to drag and sort your pictures.

Usage

screenshot

screenshot

  1. setup

most simple like :

<div id="upload"></div>
<script>
$('#upload').HHuploadify({
    uploader:'upload.php'
});
</script>

uploader setting is needed!

  1. single

print only one upload item, can only select one picture

<div id="upload"></div>
<script>
$('#upload').HHuploadify({
    uploader: 'upload.php',
    single: true
});
</script>

upload button hidden when picture is selected

  1. item title

show notice words on the side of every item, like the screenshot show

<div id="upload"></div>
<script>
$('#upload').HHuploadify({
    uploader: 'upload.php',
    single: true,
    itemTitle: 'Thumbnail'
});
</script>
  1. several

show several item, ervery item is a single uploader.

<div id="upload"></div>
<script>
var selector = '#upload',
    num,
    id
    itemTitles = ['Title1','Title2','Title3'];
for(i = 0;i < itemTitles.length;i ++) {
    num = i + 1;
    id = decodeURIComponent(selector.replace('#','').replace('.','').replace(' ','-')) + num;
    html = '<span id="' + id + '" class="uploadify-container"></span>';
    title = itemTitles[i];
    $(selector).append(html);

    $('#' + id).HHuploadify({
        uploader: 'upload.php',
        single: true,
        itemTitle: title
    });
}
</script>

Helpers

question: How could you submit your picture to the database? through you have uploaded the pictures, how can you record the picture to the article or other usage? just use HHuploadifyReady.js,

** Notice ** uploader should return json string like {key:value}, and should give status, id, url fields:

{
    status : 1,
    id : 5,
    url : '/uploads/test.jpg'
}

status=1 means success, status=0 means failed. when status=1, the item area will append a <input type="hidden">, its value will use id field, if your preview option set to 2, url field will be used.

read demo/ready.html

More

About

基于Huploadify(基于uploadify)的图片上传插件,自动上传,上传进度条,上传后预览

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 73.6%
  • HTML 12.2%
  • CSS 11.4%
  • PHP 2.8%