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.

Sam
  • 1,564
  • 4
  • 23
  • 37
  • I understand there are a few questions like this, but none of their answers satisfy me. – Sam Jan 26 '13 at 22:08
  • Use a jQuery plugin, or a bootstrap plugin. http://www.fyneworks.com/jquery/multiple-file-upload/ – Austin Jan 26 '13 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. – aufziehvogel Jan 26 '13 at 22:10
  • I considered the zip file but my client isn't very adept with anything computer. – Sam Jan 26 '13 at 22:12
  • @Austin thanks, but unfortunately the user will still have to click on multiple forms. – Sam Jan 26 '13 at 22:14
  • This is not possible without HTML5 or Flash. – cheesemacfly Jan 26 '13 at 22:16
  • http://stackoverflow.com/questions/2704314/multiple-file-upload-in-php?rq=1 read it – Parimal Raj Jan 26 '13 at 22:17
  • @AppDeveloper Did you fully read my question? Thanks for the link, but it does not help. I know PHP can handle multiple image uploads, but I need the user to be able to select multiple at once. I understand I need Flash/Java etc, but I can't find a solution that someone without JS knowledge can integrate. – Sam Jan 26 '13 at 22:20
  • well then u have to do it with little bit of JavaScript! – Parimal Raj Jan 26 '13 at 22:22
  • I can implement a JavaScript solution if it is properly documented as to how you do so. A lot of the solutions just say, "here is the app, here are the options" with minimal setup instruction. – Sam Jan 26 '13 at 22:25

2 Answers2

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

Community
  • 1
  • 1
Parimal Raj
  • 20,189
  • 9
  • 73
  • 110
  • 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. – Sam Jan 26 '13 at 22:21
  • 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. – Paul Draper Nov 06 '13 at 19:12
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.

u01jmg3
  • 712
  • 1
  • 11
  • 31
  • 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. – Sam Jan 26 '13 at 22:27
  • 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. – u01jmg3 Jan 26 '13 at 22:34