icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » PHP FTP Help

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old November 13th, 2005, 7:44 PM   #1 (permalink)
Surpass Fan
Comfy Contributor
 
HostGlory's Avatar
 
Joined in May 2004
Lives in South Dakota
Hosted on Liquid
132 posts
Gave thanks: 0
Thanked 0 times
PHP FTP Help

Ok, here's the problem. I'm writing a new PHP FTP program for my website UploadSystem.com. I'm at the point where I'm trying to upload a file, but it seems as though server settings have placed a bottleneck on my progress. Here's the error:

Warning: move_uploaded_file(): open_basedir restriction in effect. File(/boatreceipt.gif) is not within the allowed path(s): (/home/phpconsu/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/phpconsu/public_html/uploadsystem/include/classes.inc.php on line 368


Is there anyway around this? I know PHP pretty well, so I'm not sure who can actually help me on this problem.
__________________
Thanks!
Brandon

Dedicated Servers:
liquid.hostglory.com

www.modmyspace.com
www.uploadsystem.com
HostGlory is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 13th, 2005, 8:10 PM   #2 (permalink)
All Ur Base R Belong 2 Us
Excelling Contributor
 
mr_fern's Avatar
 
Joined in Feb 2005
Lives in Vegas & New York
824 posts
Gave thanks: 2
Thanked 6 times
Error seems to stem from the path of the uploaded file, or the destination you've set for that file. I'm assuming it would be the uploaded file's path, from the error would appear to be "/boatreceipt.gif"

PHP Code:
$from_file $_FILES[formNameForUpload][tmp_name];
$to_file "/path/to/uploadFolder/" $_FILES[formNameForUpload][name];

move_uploaded_file($from_file,$to_file); 
__________________
Nobody doing nothing
mr_fern is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 13th, 2005, 8:26 PM   #3 (permalink)
Surpass Fan
Comfy Contributor
 
HostGlory's Avatar
 
Joined in May 2004
Lives in South Dakota
Hosted on Liquid
132 posts
Gave thanks: 0
Thanked 0 times
Well, the code there is exactly what I have right now. I believe it may actually be a setting in PHP with the safe_mode variable set to off. From what I've gathered, PHP checks the authenticity of a file being uploaded by the user who uploads it. Every folder has a user associated with it, and if the user name who's uploading a file doesn't match the user of the folder the file is being uploaded to, then it gives this error.
__________________
Thanks!
Brandon

Dedicated Servers:
liquid.hostglory.com

www.modmyspace.com
www.uploadsystem.com
HostGlory is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 13th, 2005, 8:30 PM   #4 (permalink)
All Ur Base R Belong 2 Us
Excelling Contributor
 
mr_fern's Avatar
 
Joined in Feb 2005
Lives in Vegas & New York
824 posts
Gave thanks: 2
Thanked 6 times
That would cause the problem. Are you uploading from one website to another? I was under the impression that you were using the uploadsystem.com site to have users upload to uploadsystem.com, if it's a different set up, what's the set up like
__________________
Nobody doing nothing
mr_fern is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 13th, 2005, 8:39 PM   #5 (permalink)
Surpass Fan
Comfy Contributor
 
HostGlory's Avatar
 
Joined in May 2004
Lives in South Dakota
Hosted on Liquid
132 posts
Gave thanks: 0
Thanked 0 times
Ok, I played around with path of the file being uploaded and I seem to have gotten it to work. But, the actual file itself isn't uploaded, just the filename is created with the code I'm using at the moment. The safe_mode variable isn't an issue. And, I'm trying to accomplish giving users the ability to upload files from their local computer. Anyway, here's the code I'm playing with:

PHP Code:

$filename 
basename($_FILES['putFile']['name']);
$tmpname $_FILES['putFile']['tmp_name'];
$uploadfile "/tmp/" $filename;

if (!
move_uploaded_file($tmpname$uploadfile))
    {
    
message("Can't create temporary file", @$php_errormsg);
    
unlink($tmpfile);
    }
else
    {
    
ftp_put($this->CONN_ID$filename$tmpfileFTP_BINARY);
    } 
__________________
Thanks!
Brandon

Dedicated Servers:
liquid.hostglory.com

www.modmyspace.com
www.uploadsystem.com
HostGlory is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 13th, 2005, 9:29 PM   #6 (permalink)
All Ur Base R Belong 2 Us
Excelling Contributor
 
mr_fern's Avatar
 
Joined in Feb 2005
Lives in Vegas & New York
824 posts
Gave thanks: 2
Thanked 6 times
I believe since you're trying to move the file into /tmp/ is the reason you're getting the error. On my site I move it from the uploaded file into /home/myuser/public_html/tmp/(file)

As you were mentioning earlier, I don't believe the php page has access to writing files in the tmp directory directly (as in the case of the move), so try moving the file to another path, and that should work. At least my experience with the scenario tells me so.
__________________
Nobody doing nothing
mr_fern is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 13th, 2005, 9:53 PM   #7 (permalink)
Surpass Fan
Comfy Contributor
 
HostGlory's Avatar
 
Joined in May 2004
Lives in South Dakota
Hosted on Liquid
132 posts
Gave thanks: 0
Thanked 0 times
Ok, here's my updated code. It doesn't give me any errors, but it still will not upload the file:

PHP Code:
srand((double)microtime()*1000000);
        
$randval rand();
        
$tmpname $filename ."."$randval;
        
        
        
        if (!
ftp_put($this->CONN_ID$tmpdir.$tmpname$filenameFTP_BINARY))
            {
            
            
move_uploaded_file($tmpdir.$tmpnameftp_pwd($this->CONN_ID).$filename);
            }
        else
            {
            
message("Can't create temporary file", @$php_errormsg);                
            
unlink($tmpname);
            } 
If you could post an example of what you have for your code, that would greatly be appreciated. If you do that, then I can maybe figure out what's going on here.
__________________
Thanks!
Brandon

Dedicated Servers:
liquid.hostglory.com

www.modmyspace.com
www.uploadsystem.com
HostGlory is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 13th, 2005, 10:11 PM   #8 (permalink)
All Ur Base R Belong 2 Us
Excelling Contributor
 
mr_fern's Avatar
 
Joined in Feb 2005
Lives in Vegas & New York
824 posts
Gave thanks: 2
Thanked 6 times
Well some of the specifics have been stripped, but here's the basic jist of my code

PHP Code:
    $f_destination $pic_path ."/"substr(md5(microtime()),0,6) . ".jpg";
    
    
$filename $_FILES[photo][name];
    
$tempfile $_FILES[photo][tmp_name];

    
$move move_uploaded_file($tempfile,$f_destination);

    if (!
$move) {
        
$up_error "File Not Successfully Uploaded.";
        return;
    }

    
// SOME DB QUERIES
    // Inserts/Selects

    
$picture_id $row[0];
    
$new_filename "$pic_path/$picture_id.jpg";

    
rename($f_destination,$new_filename);

    
$ftp_link ftp_connect(location);
    
$ftp_login_success ftp_login($ftp_linkuserpass);
    
$upload_pic ftp_put($ftp_link"/picture_path/$picture_id.jpg"$new_filenameFTP_BINARY);
    
ftp_close($ftp_link);
    
    
unlink($new_filename); // delete local file 
__________________
Nobody doing nothing
mr_fern is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old November 14th, 2005, 3:40 PM   #9 (permalink)
Surpass Fan
Comfy Contributor
 
HostGlory's Avatar
 
Joined in May 2004
Lives in South Dakota
Hosted on Liquid
132 posts
Gave thanks: 0
Thanked 0 times
Ok, I'm returning with my problem, but I have some more insight on how things need to work. Here's my code now and below that the error I receive:

PHP Code:
$destination $workingdir "/" $_SESSION['ftp_username'] ."/"basename($tmpname);
    
        echo 
$tmpname ."<br>";
        
        
$move move_uploaded_file($tmpname$destination);

           if (!
$move)
            {
            
message("Can't create temporary file", @$php_errormsg);
            }
        else    
            {
            
rename($destination$workingdir "/" $_SESSION['ftp_username'] ."/"$filename);

            if (!
ftp_put($this->CONN_ID$workingdir "/" $_SESSION['ftp_username'] . $filename $filenameFTP_BINARY))
                {
                
message("Can't upload file", @$php_errormsg);
                }
            } 
Quote:
Warning: move_uploaded_file(/home/phpconsu/uploadsystem/brandon/phpnZS4UC): failed to open stream: No such file or directory in /home/phpconsu/public_html/uploadsystem/include/classes.inc.php on line 372

Warning: move_uploaded_file(): Unable to move '/tmp/phpnZS4UC' to '/home/phpconsu/uploadsystem/brandon/phpnZS4UC' in /home/phpconsu/public_html/uploadsystem/include/classes.inc.php on line 372
Can't create temporary file
__________________
Thanks!
Brandon

Dedicated Servers:
liquid.hostglory.com

www.modmyspace.com
www.uploadsystem.com
HostGlory is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On