OK here is my multiple file uploading file script
<input type="file" name="userfile[]" size="20" enctype="multipart/form-data">
i have 4 upload file inputs
in my page
and the php script im using is
$files = $HTTP_POST_FILES['userfile'];
if(!empty($userfile[0])) {
if(is_uploaded_file($userfile[0])){
move_uploaded_file($userfile[0], "/ft_files/1.jpg");
}
}
when i upload a file using the first input… i dont know why it doesnt upload the file… could someone help me??? at php.net they said for multiple uploads use ‘userfile’ as an array
thanks
system
September 1, 2003, 5:38pm
2
actually, its this:
$files = $HTTP_POST_FILES["userfile"];
if(!empty($userfile[0])) {
if(is_uploaded_file($userfile[0])){
move_uploaded_file($userfile[0], "/ft_files/1.jpg");
}
}
always use double quotes with arrays.
system
September 1, 2003, 5:44pm
3
tried it dint work … the path is it relative to the folder the php file is in?
system
September 1, 2003, 5:57pm
4
try
$files = $_FILES['userfile'];
if(!empty($files[0])) {
if(is_uploaded_file($files[0])){
move_uploaded_file($files[0], "/ft_files/1.jpg");
system
September 1, 2003, 7:12pm
5
nope that dint work either dont know wats wrong… i have even made sure the folder is chmod to write
system
September 1, 2003, 7:18pm
6
ok this is what i did
$files = $_FILES['userfile'];
echo $userfile[0];
and the result i got was
C:\Documents and Settings\user\Desktop
ame.jpg
how do i remove the \ and make it only \
?? thanks i think that might work
system
September 1, 2003, 7:55pm
7
ok i tried this out
$userfile = str_replace("\\", "\", $userfile);
now that worked but this is what happened to the result…
C:\Documents and Settings\user\Desktop
ame.jpg
same result then i tried changing it to another charc to see if the str_replace works and it worked
i replaced the \ with + and it worked and i got this as the result
C:++Documents and Settings++user++Desktop++name.jpg
why is it doubling that char ? i dont understand
system
September 1, 2003, 8:18pm
8
ok i figured it out i just did this
$userfile = str_replace("\\\\\\\\", "\\\\", $userfile);
to get this
C:\Documents and Settings\user\Desktop
ame.jpg
dint understand why thou …
BUTT the
$files = $HTTP_POST_FILES["userfile"];
if(!empty($userfile[0])) {
if(is_uploaded_file($userfile[0])){
move_uploaded_file($userfile[0], "/ft_files/1.jpg");
}
}
still aint working
system
September 1, 2003, 9:14pm
9
I was thinking do i have to put
/var/www/html/
or something before the url?
system
September 4, 2003, 8:03pm
10
try with copy()
if(@is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
copy($_FILES['userfile']['tmp_name'], "/ft_files/1.jpg");
}