Jump to content

Problem Uploading File


Recommended Posts


I'm having issues uploading a file file to my server with a very small and simple script. It works when I do not create a new folder and leave everything in the Uploads folder but I would like to create an individual folder with the ticket number provided in the form and store all submited files there.


		$ticket_number = $_POST['ticketnumber'];

		mkdir("uploads/$ticket_number", 0777);
		chmod("uploads/", 0777);
		chmod("uploads/$ticket_number", 0777);

		$mydir = "uploads/$ticket_number";

		if(chmod(realpath($myDir), 0777)) { echo 'Successfully changed dir to 0777 permissions!'; } 

		$target_path = "uploads";

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

		echo 'Permissions: ' . substr(sprintf('%o', fileperms($mydir)), -4); 
		// Result here is 0777


The paths are all fine. Here are the errors I get:


Warning: move_uploaded_file(uploads/ww) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Documents and Settings\jack.ponte\Desktop\Website\logs\uploader.php on line 56



Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'c:/wamp/tmp\php13E.tmp' to 'uploads/ww' in C:\Documents and Settings\jack.ponte\Desktop\Website\logs\uploader.php on line 56



Any help will be appreciated.


Jack P

Link to comment
Share on other sites


Thanks PFMaBiSmAd. As you said, I did not have the file name to be write, So I added/changed  the following 3


$target_path = "uploads/$ticket_number/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {





Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

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

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.