Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One click upload button

I am looking to create a button which when clicked opens a dialog window where they select an image to upload and then once they select it and press ok within the dialog window the upload begins (upload bar optional :) )

Preferable it would be a jquery plugin that modifys the functionality of the standard html file input... as I have already written the code using one.

like image 252
Pablo Avatar asked Jul 10 '10 09:07

Pablo


People also ask

How do you create an HTML file to upload?

The <input type="file"> defines a file-select field and a "Browse" button for file uploads. To define a file-select field that allows multiple files to be selected, add the multiple attribute. Tip: Always add the <label> tag for best accessibility practices!


4 Answers

JQuery plugin uploadify will upload with a progress bar, and includes functionality for single or multiple file uploads.

like image 131
Christian Payne Avatar answered Nov 22 '22 14:11

Christian Payne


SWFUpload is able to do that. It is a Flash-based upload component that you can interact with using JavaScript.

Demo

like image 20
Pekka Avatar answered Nov 22 '22 13:11

Pekka


There are other flash based solutions other than SWFupload. Have a look at uploadify.com

This is a jquery plugin.

like image 28
dalton Avatar answered Nov 22 '22 14:11

dalton


there is some cheat to do this using jquery and ordinary html. this is what i use in my project to upload one file (limited to one) and just using one button and no plugin whatsoever although it's button needs styling.

HTML code

<form method="get" action="somephp.php">
                <input type="file" id="upload" name="upload" style="width: 88px; opacity:0.0; filter:alpha(opacity=0); " onchange='uploadChange()'/>
                <input type="submit" name="submit" style="margin-left: -88px"/>
            </form>

jquery :

<script>
    function uploadChange(){
        $('input[type="submit"]').click();
    }
</script>
like image 28
DennyHiu Avatar answered Nov 22 '22 14:11

DennyHiu