Jump to content

[SOLVED] Uploading new files via form CHMODS to 600?


Recommended Posts

I have a fully functional user upload form now which I am pleased about, however the uploaded files cannot be deleted as they are uploaded with permissions of '600'.

 

Is there any way in this script I can change it so that all uploaded files are automatically set to '755'?

 

<?php
	// If there is no such folder yet, create one
			 $upload_save_dir = $user_id;

                if(!file_exists($target_path)){ 

					mkdir($target_path);
					echo "A folder has been created for user '$FileUser'<br />";

				}

		/* Add the original filename to our target path.  
		Result is "uploads/filename.extension" */
		$target_path = $target_path . basename( $_FILES['FileName']['name']); 
		$_FILES['FileName']['tmp_name'];  


		if(move_uploaded_file($_FILES['FileName']['tmp_name'], $target_path)) {

			echo "The file ".  basename( $_FILES['FileName']['name']). " has been uploaded<br />";
		} else{
			echo "There was an error uploading the file, please try again!<br />";
		}
?>

Solved it....

 

	<?php	
if(move_uploaded_file($_FILES['FileName']['tmp_name'], $target_path)) {
			chmod($target_path, 0755);
			echo "The file ".  basename( $_FILES['FileName']['name']). " has been uploaded<br />";
		} else{
			echo "There was an error uploading the file, please try again!<br />";
		}?>

 

Thanks Nathan!

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.