Uploading Files Trouble

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Uploading Files Trouble

Post by DuFF »

Ok, this is one of the wierdest things I've ever experienced with PHP. I was given free hosting by someone who I helped make a PHP script for. He needed an uploading script so I worked on it, tested it out on my domain and it worked. Then I gave it to him and now it gives this wierd error.

Warning: move_uploaded_file(): open_basedir restriction in effect. File(/submissions/installsubmissions.zip) is not within the allowed path(s): (/home/rctdload:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/rctdload/public_html/submissions.php on line 95

Now, I looked into open_basedir and basically what it does is restrict PHP from opening any files above a certain directory. This is one of safe_mode's options. It works whether safe_mode is on or not, so thats not the problem.

The wierdest thing is that both he and I are under the same account so we have exactly the same PHP.ini and are using the exact same PHP Script.
Heres the code near Line 95:

Code: Select all

<?php
        $uploaddir = "/submissions/";
        $filename=$_FILES['userfile']['name'];
        $filetemp=$_FILES['userfile']['tmp_name'];
        $dirfile = $uploaddir;
        $dirfile .= $fileoriginalname;
//...
if (is_uploaded_file($filetemp)){
        if (move_uploaded_file($filetemp,$dirfile))  //LINE 95
        {
//... removed irrelevant code

?>
Does anyone have any ideas?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Try

Code: Select all

$uploaddir =$_SERVER['DOCUMENT_ROOT'].'/submissions/';
move_uploaded_file expects an absolute path not a relative one, so presuming /submissions is in your documentroot you should be ok.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Yup. As stated here: [php_man]move_uploaded_file[/php_man] ...In the last comment. :)
Post Reply