• Notice regarding image hosts and attachments. See here.

PHP file upload

Associate
Joined
24 Apr 2007
Posts
545
Location
Rochford
Hey all, having some trouble with uploading files using PHP. I've followed 3 or 4 different examples of it from t'interwebs, but none of them seem to work for me. Whenever I try, I always get this error:

Notice: Undefined index: fileRecipePicture in /Users/naudiz/Sites/FYP2/createrecipe.php on line 26

I've got the form with the right enc type to do file upload, and the input type has a name of fileRecipePicture. Here's the current PHP for it.

Code:
$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['fileRecipePicture']['name']); 
	
if(move_uploaded_file($_FILES['fileRecipePicture']['tmp_name'], $target_path)) 
{
    	echo "The file ".  basename( $_FILES['fileRecipePicture']['name']). " has been uploaded";
} 
else
{
   	echo "There was an error uploading the file, please try again!";
}
 
Back
Top Bottom