Jump to content

[SOLVED] undefined index file upload


abazoskib

Recommended Posts

ok so im doing something really simple and i cant get why its not working. i am trying to upload a file to a folder with proper permissions.

 

i have the form and the process code on the same page:

 

///////////////
//PROCESS UPLOADED FILE
///////////////

if(isset($_POST['processFile'])) {
$target_path = "/home/content/c/j/o/cjoday/camPanel/uploads/";
$target_path = $target_path . basename( $_FILES['uploaded']['name']); 
$temp_path = $_FILES['uploaded']['tmp_name'];
if(move_uploaded_file($temp_path, $target_path)) {
	//file uploaded
} else{
	//file not uploaded
}
}

 

<form enctype="multipart/form-data" method="post">
									Or upload a new a file: <input name="uploaded" type="file" /><br />
									<input type="submit" name="processFile" value="Process File" />
								</form> 

 

print_r($_FILES) returns an empty array and I keep getting an error:

 

Notice: Undefined index: uploaded in Panel/utilities.php on line 54

Notice: Undefined index: uploaded in Panel/utilities.php on line 55

 

ive searched everywhere but all the answers point to not having the enctype attribut of the form.

Link to comment
https://forums.phpfreaks.com/topic/176886-solved-undefined-index-file-upload/
Share on other sites

If the line numbers mentioned in the errors you posted corresponds to the code that is inside of the if(isset($_POST['processFile'])) { logic, then it is likely that your code is overwriting the $_FILES array. Another possibility would be invalid nested form tags. You would need to post your actual code for someone to be able to determine which out of the several possible reasons it is not working.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.