2

I'm on a very tight deadline and need to get a file upload script integrated with an admin panel I wrote.

Basically the user needs to be able to upload multiple images that I can then process with PHP. I could use multiple input tags but if they want to upload 10 images it will be a huge hassle (this would be the norm).

The main problem here is that I don't know Javascript, Java or Flash and users will need to use Internet Explorer < 10 so HTML5 can't be used. I have knowledge of PHP, MYSQL, HTML, CSS, but it's not helping with the clientside.

I've looked at many solutions and spent far to many hours trying to find a solution myself. I need something that I can integrate with my current knowledge, I don't have time to learn Javascript. This is why I am having so much trouble trying to integrate fully fledged systems such as plupload, SWFupload and uploadify.

I tried for over an hours to get uploadify to work, but it just isn't playing nice.

If anyone has a simple solution please let me know. I simply want to be able to upload multiple files with one input tag. No resizing, no flash interface as this will all be handled by the server using my script. The user must be able to select multiple images at once though.

10
  • I understand there are a few questions like this, but none of their answers satisfy me. Commented Jan 26, 2013 at 22:08
  • Use a jQuery plugin, or a bootstrap plugin. fyneworks.com/jquery/multiple-file-upload Commented Jan 26, 2013 at 22:10
  • I do not know the new HTML5 features yet, but up to HTML4 this was not possible without help from other tools. The only idea is to use a zip file and extract it. There is a PHP library for this. Commented Jan 26, 2013 at 22:10
  • I considered the zip file but my client isn't very adept with anything computer. Commented Jan 26, 2013 at 22:12
  • @Austin thanks, but unfortunately the user will still have to click on multiple forms. Commented Jan 26, 2013 at 22:14

2 Answers 2

7

Multiple files can be selected and then uploaded using the
<input type='file' name='file[]' multiple>
The sample php script that does the uploading:

<html>
<title>Upload</title>
<?php
    session_start();
    $target=$_POST['directory'];
        if($target[strlen($target)-1]!='/')
                $target=$target.'/';
            $count=0;
            foreach ($_FILES['file']['name'] as $filename) 
            {
                $temp=$target;
                $tmp=$_FILES['file']['tmp_name'][$count];
                $count=$count + 1;
                $temp=$temp.basename($filename);
                move_uploaded_file($tmp,$temp);
                $temp='';
                $tmp='';
            }
    header("location:../../views/upload.php");
?>
</html>

The selected files are received as an array with

$_FILES['file']['name'][0] storing the name of first file.
$_FILES['file']['name'][1] storing the name of second file.
and so on.


Credit :

Multiple file upload in php
Uploading Tutorial

Sign up to request clarification or add additional context in comments.

2 Comments

As I understand it, this will not work in Internet Explorer. Is there are way to make it work? If it was backwards compatible then I would use it.
IE does not support the multiple attribute of input. The only way to do multiple file upload in IE is to use a plugin, like Flash.
0

For a recent project I went through this same process of trying out the plugins available at the moment that allow multiple uploads without the need of flash or HTML5 and I came across this jQuery plugin: MultiFile 1.48 Out the box it looks a little ugly but with heavy editing of the CSS, it can look good. I also edited the JS to include functions such as the cancelling of an upload but you would need to know JavaScript/jQuery before you can do this.

2 Comments

Thanks, Austin posted the same solution above. Unfortunately this doesn't allow you to select multiple at once (using CTRL). I understand that Flash etc is required, but implementations of such solutions seems difficult.
The standard file browser that opens up (when you click Browse (IE, etc) or Choose File (Chrome)) just can't handle selecting multiple files. Flash or HTML5 use a different file browser dialog which is why you can support multiple file selection, drag and drop, etc. Most HTML5 features that are not supported in IE10 can be implemented with plugins if you choose an HTML5 solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.