Uploading multiple PHP files

I'm in a very tight deadline and need to download a script file that is integrated with the admin panel I wrote.

Basically the user should be able to upload multiple images that I can process with PHP. I could use multiple tags input

, but if they wanted to upload 10 images, that would be a huge problem (that 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 cannot be used. I have knowledge of PHP, MYSQL, HTML, CSS, but it doesn't help clients.

I have looked at many solutions and spent a lot of time trying to find the 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 have so many problems trying to integrate full systems like plupload, SWFupload and uploadify.

I've tried for over an hour to get it up to work, but it just doesn't play well.

If anyone has a simple solution please let me know. I just want to be able to upload multiple files with one tag input

. No resizing, no flash interface as this will all be handled by the server using my script. The user should be able to select multiple images at the same time.

+2


source to share


2 answers


Multiple files can be selected and then downloaded using a   <input type='file' name='file[]' multiple>


sample php script that does the upload:

<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]

save the name of the first file.
$_FILES['file']['name'][1]

save the name of the second file.
etc.




Credit:

Loading multiple files in php
Loading the tutorial

+7


source


For a recent project, I went through this same process of testing currently available plugins that allow multiple uploads without the need for flash or HTML5, and I came across this jQuery plugin: MultiFile 1.48 Out of the box it looks a little ugly, but with heavy CSS editing, it may look good. I also edited the JS to include features like cancellation of loading, but you will need to know JavaScript / jQuery before you can do this.



0


source







All Articles