Uploading multiple files

equipemis

New Member
Messages
12
Reaction score
0
Points
0
[SOLVED]Uploading multiple files

Hi guys,

I have a problem. I am trying to upload 8 files at the same time.

So I have this as my form:
Code:
<form action="upload.php" ENCTYPE="multipart/form-data" method="post">
players.ehm: <input id="file1" type="file" name="file1"><br/>
teams.ehm: <input id="file2" type="file" name="file2"><br/>
statistics.ehm: <input id="file3" type="file" name="file3"><br/>
league.ehm: <input id="file4" type="file" name="file4"><br/>
schedule.ehm: <input id="file5" type="file" name="file5"><br/>
histories.ehm: <input id="file6" type="file" name="file6"><br/>
draftpicks.ehm: <input id="file7" type="file" name="file7"><br/>
<input type="submit" value="Upload!">

And this is upload.php:
Code:
<?php
$directory_self = getcwd();
for($i = 1; $i < 8; $i++){
$file_name = $_FILES['file'. $i]['name'];
// strip file_name of slashes
$file_name = stripslashes($file_name);
$file_name = str_replace("'","",$file_name);
$copy = move_uploaded_file($_FILES['file'. $i]['tmp_name'],$directory_self);
 // prompt if successfully copied
}
if($copy){
print "Les fichiers ont ete uploader<br/><a href='start_update.php'>Continuer</a>";
}
else
{
echo "Une erreur s'est produite!</br> <a href='form.php'>Re-essayer</a>";
 }
?>


But I get this error:
Warning: move_uploaded_file(/home/equipemi/public_html/converter) [function.move-uploaded-file]: failed to open stream: Is a directory in /home/equipemi/public_html/converter/upload.php on line 8

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpMD388V' to '/home/equipemi/public_html/converter' in /home/equipemi/public_html/converter/upload.php on line 8

The converter folder has 777 of permission so does the upload.php file.


Thanks for your help,
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
The second arguement to move_uploaded_file is the name of the destination file, not a directory (as you have it).

Sort of like

Code:
$copy = move_uploaded_file($_FILES['file'. $i]['tmp_name'],$directory_self . '/' . $file_name );

but you should double check you are not overwriting an existing file.
You should also sanitize the input a bit more.
 
Last edited:
Top