Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.