The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
For the path you can try something like
$_SERVER["DOCUMENT_ROOT"]. '/path/to/my/upload/dir/'. $filename
which is an absolute path. Or you can specify a path relative to the script thats currently running eg...
'path/to/my/upload/dir/'.$filename
have tried both.
Code:
$uploaddir = $_SERVER["DOCUMENT_ROOT"].'/htdocs/camra/pubs/';
$uploadfile = $uploaddir . basename( $_FILES['userfile']['name'] );
if ( move_uploaded_file( $_FILES['userfile']['tmp_name'], $uploadfile ) ) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Failed to upload file\n";
}
Error:
Failed to upload file
Warning: move_uploaded_file( /usr/local/www/data/htdocs/camra/pubs/aaaa.jpg ): failed to open stream:
No such file or directory in /freeola/users/0/7/sr0109170/htdocs/camra/edit/SavePub.php on line 214
Warning: move_uploaded_file(): Unable to move '/var/tmp/phpXDIy80' to '/usr/local/www/data/htdocs/camra/pubs/aaaa.jpg'
in /freeola/users/0/7/sr0109170/htdocs/camra/edit/SavePub.php on line 214
It looks like php does not like my path to the upload directory. I have also tried /htdocs/camra/pubs/ with the same results.
> Error:
> Failed to upload file
> Warning: move_uploaded_file(
> /usr/local/www/data/htdocs/camra/pubs/aaaa.jpg ): failed to open
> stream:
> No such file or directory in
> /freeola/users/0/7/sr0109170/htdocs/camra/edit/SavePub.php on
> line 214
>
Well at least the error is showing you the correct path. Freeola are using virtual hosts I guess so you cant trust the output of $_SERVER["DOCUMENT_ROOT"]
Try this...
$uploaddir = '/freeola/users/0/7/sr0109170'. '/htdocs/camra/pubs/';
you're a star. Path and permissions are now correct and it's all working. The joys of a virtual host! many thanks.
is_uploaded_file ($_FILES['uploaded'])
but when I try and use
move_uploaded_file( $_FILES['uploaded']['tmp_name'], 'destination')
I get errors and what's worse, the 'destination' file is erased without the uploaded file replacing it.
Is this going to get fixed or am I going to have to look for a new host?
Warning: file() [function.file]: open_basedir restriction in effect. File(/var/tmp/php7qIxvl) is not within the allowed path(s): (/freeola/users) in /freeola/users/2/9/sr0xxxxx2/htdocs/ chatroom/store_profile_picture.php on line 177
Warning: file(/var/tmp/php7qIxvl) [function.file]: failed to open stream: Operation not permitted in /freeola/users/2/9/sr0xxxxx2/htdocs/ chatroom/store_profile_picture.php on line 177
If I try and use move_uploaded_file() to move the file to another directory I get:
Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File(/var/tmp/phpI9Nq6l) is not within the allowed path(s): (/freeola/users) in /freeola/users/2/9/sr0xxxxx2/htdocs/ chatroom/store_profile_picture.php on line 177
Warning: move_uploaded_file(/var/tmp/phpI9Nq6l) [function.move-uploaded-file]: failed to open stream: Operation not permitted in /freeola/users/2/9/sr0xxxxx2/htdocs/ chatroom/store_profile_picture.php on line 177
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/phpI9Nq6l' to '/freeola/users/2/9/sr0xxxxx2/htdocs/ chatroom/trevnsime.jpg' in /freeola/users/2/9/sr0xxxxx2/htdocs/ chatroom/store_profile_picture.php on line 177
Both these were working perfectly a day or so ago.
Is there a way to set the upload file directory for uploads so it's not /var/tmp/, or include /var/tmp/ in the open_basedir restriction?