Jump to content

Recommended Posts

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?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/198888-move_uploaded_file-uid-not-allowed/
Share on other sites

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.

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.. :confused:

 

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?

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.

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.

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.

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.