shane201980 Posted April 18, 2010 Share Posted April 18, 2010 I originally had a problem with downloading files from mysql database, which after being fixed I realized that my biggest problem is the file was never uploaded, just the information about the file. Anyhow, I have spent several hours reconfiguring my script to upload to and move_uploaded_file which I was missing. I used path instead of URL because that's the only way it would work. Now my problem is as follows: [sat Apr 17 16:39:22 2010] [error] [client 98.***.**.***] PHP Warning: move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: SAFE MODE Restriction in effect. The script whose uid is 10231 is not allowed to access / owned by uid 0 in /var/www/vhosts/someplace.com/httpdocs/Documents/project_input.php on line 123, referer: http://someplace.com/Documents/project_add.php From researching this, it seems that there is a permission problem or safe mode problem. Well I use a hosting service and I am not sure if I can get them to turn safe mode off (which is preferrable), but I know that there are work arounds and that is what I am hoping for. Is there a way to insert the correct uid for this form? Anyway to work around safe mode restriction? Here is a portion of code that I am using to perform this action: $fileName = $_FILES['plans']['name']; $tmpName = $_FILES['plans']['tmp_name']; $fileSize = $_FILES['plans']['size']; $fileType = $_FILES['plans']['type']; $target_path = "/someplace.com/httpdocs/Documents/uploads/"; $target_path = $target_path . basename( $_FILES['plans']['name']); if(move_uploaded_file($_FILES['plans']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/198888-move_uploaded_file-uid-not-allowed/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 18, 2010 Share Posted April 18, 2010 Your target path should be something like - /var/www/vhosts/someplace.com/httpdocs/Documents/uploads/ What you currently have in the code is a folder /someplace.com/.... starting in the root of the current drive, which even if it existed, you likely don't have permission to access. Quote Link to comment https://forums.phpfreaks.com/topic/198888-move_uploaded_file-uid-not-allowed/#findComment-1043994 Share on other sites More sharing options...
shane201980 Posted April 18, 2010 Author Share Posted April 18, 2010 I shortened it because of permissions. I figured that I did not have access any higher than the path I typed. It seemed like it was working.. But now back to an old problem, I now get these errors: [sat Apr 17 18:03:10 2010] [error] [client 98.***.**.***] PHP Warning: move_uploaded_file(/var/www/vhosts/someplace.com/httpdocs/Documents/uploads/Test_file.pdf) [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: failed to open stream: Permission denied in /var/www/vhosts/someplace.com/httpdocs/Documents/project_input.php on line 122, referer: http://someplace.com/Documents/project_add.php [sat Apr 17 18:03:10 2010] [error] [client 98.***.**.***] PHP Warning: move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: Unable to move '/tmp/phphR8pgT' to '/var/www/vhosts/someplace.com/httpdocs/Documents/uploads/Test_file.pdf' in /var/www/vhosts/someplace.com/httpdocs/Documents/project_input.php on line 122, referer: http://someplace.com/Documents/project_add.php Any ideas from this point? Quote Link to comment https://forums.phpfreaks.com/topic/198888-move_uploaded_file-uid-not-allowed/#findComment-1043995 Share on other sites More sharing options...
darkfreaks Posted April 18, 2010 Share Posted April 18, 2010 1.) make sure your target path is correct. 2.) make sure the folder and path to folder actually exist. Quote Link to comment https://forums.phpfreaks.com/topic/198888-move_uploaded_file-uid-not-allowed/#findComment-1043998 Share on other sites More sharing options...
PFMaBiSmAd Posted April 18, 2010 Share Posted April 18, 2010 The uploads folder does not have the necessary ownership or permissions for the web server to access it. What method did you use to create that folder? If you use a .php script to create the folder, it will have the correct ownership. If you use your hosting control panel it (should) have the necessary ownership. If you used your FTP client, the folder will be owned by the owner that the FTP server is running under. Quote Link to comment https://forums.phpfreaks.com/topic/198888-move_uploaded_file-uid-not-allowed/#findComment-1043999 Share on other sites More sharing options...
shane201980 Posted April 18, 2010 Author Share Posted April 18, 2010 I created the folder through the host control panel (Plesk 8.4.0). I did try to use mkdir() to add the folder through php, but it gives me this error. [sat Apr 17 19:30:08 2010] [error] [client 68.***.***.***] PHP Warning: mkdir() [<a href='function.mkdir'>function.mkdir</a>]: Permission denied in /var/www/vhosts/someplace.com/httpdocs/Documents/adddir.php on line 2 Here is the code I used: <?php mkpath ("/var/www/vhosts/someplace.com/httpdocs/Documents/uploads") ?> First time trying to do this so I could have screwed that up. Quote Link to comment https://forums.phpfreaks.com/topic/198888-move_uploaded_file-uid-not-allowed/#findComment-1044012 Share on other sites More sharing options...
darkfreaks Posted April 18, 2010 Share Posted April 18, 2010 obviously the folder does not have the correct permissions to access it try: mkdir('/var/www/vhosts/someplace.com/httpdocs/Documents/uploads',077,true); Quote Link to comment https://forums.phpfreaks.com/topic/198888-move_uploaded_file-uid-not-allowed/#findComment-1044020 Share on other sites More sharing options...
shane201980 Posted April 18, 2010 Author Share Posted April 18, 2010 SOLVED!!!! I feel so stupid for this one, but I noticed that I could change the actual folder permissions off on the side. So I just added write permissions. darkfreaks you are absolutely right! Thank you, you both got me through that one. Well my download still does not work correctly, but I'm closer. Quote Link to comment https://forums.phpfreaks.com/topic/198888-move_uploaded_file-uid-not-allowed/#findComment-1044022 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.