Page 1 of 1

uploadfile function not working

Posted: Mon May 15, 2006 7:04 am
by mcpalmer
Hi, having trouble with a file upload function i've created. This code works:

Code: Select all

$uploaddir = URL_SSFLASH;
$uploadfile = $uploaddir . $flashfile_name;

if (move_uploaded_file($flashfile, $uploadfile)) {
   $msg="File is valid, and was successfully uploaded.\n";
} else {
   $msg="Possible file upload attack!\n";
}
echo $msg;
I create a function that replicates this code:

Code: Select all

function uploadfiles($fileaddress, $filedest) {
	
	$filet=$filedest.$fileaddress_name;//set new destination

	if(move_uploaded_file($fileaddress, $filet)){
	
		return "File uploaded successfully";
	} else {
		return "Error uploading file";
	}
};
and use include at top of page to include file where function is and call function - i get these errors:

Code: Select all

Warning: move_uploaded_file(../swfsss/): failed to open stream: Is a directory in /home/screensa/public_html/adm/sys_func.php on line 14

Warning: move_uploaded_file(): Unable to move '/tmp/phpdDDcwK' to '../swfsss/' in /home/screensa/public_html/adm/sys_func.php on line 14
Error uploading file
what am i doing wrong here? Also using the $_FILE['flashfile']['tmp_name'] type format doesn't seem to work for me. For example $flashfile_name works fine but $_FILE['flashfile']['name'] does not. Any help much appreciated

Posted: Mon May 15, 2006 7:55 am
by BadgerC82
Could u include the make up of your function call?

Thanks

Posted: Mon May 15, 2006 10:46 am
by mcpalmer
yes it is:

Code: Select all

$msg=uploadfiles($flashfile,$filedest);

Posted: Mon May 15, 2006 11:02 am
by Burrito
try a print_r() of your $_FILES array within your function to make sure the array can be read inside your function.

Posted: Tue May 16, 2006 6:36 am
by mcpalmer
ok, got it working now, i needed to use $FILES[][] format for function to see files properly. $FILES[][] wasn't working cos i was typing $FILE[][] instead! Its always the simplest things. I think i need a php editor!