Help php!

OK here is my multiple file uploading file script


&ltinput 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

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.

tried it dint work :frowning: … the path is it relative to the folder the php file is in?

try



$files = $_FILES['userfile'];
if(!empty($files[0])) {
 if(is_uploaded_file($files[0])){
move_uploaded_file($files[0], "/ft_files/1.jpg"); 


nope that dint work either :frowning: dont know wats wrong… i have even made sure the folder is chmod to write

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

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

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 :frowning:

I was thinking do i have to put

/var/www/html/

or something before the url?

try with copy()

if(@is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
copy($_FILES['userfile']['tmp_name'], "/ft_files/1.jpg");
}