GetDotted Domains

Viewing Thread:
"File upload using php"

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.

Sat 03/06/06 at 13:09
Regular
Posts: 3
Has anyone managed to upload files from a form using php? The upload works but I cannot find the correct path when moving the file from its tempory location to where I want it.
Sat 03/06/06 at 13:09
Regular
Posts: 3
Has anyone managed to upload files from a form using php? The upload works but I cannot find the correct path when moving the file from its tempory location to where I want it.
Sat 03/06/06 at 17:06
Regular
"Devil in disguise"
Posts: 3,151
2 possibilities I suppose, either the path really is wrong or its file permission problems. Make sure you've chmod'ed the directory you want to put your files in to 777 (or maybe 755 not sure which freeola requires).

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
Sun 04/06/06 at 16:24
Regular
Posts: 3
Garin,
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.
Sun 04/06/06 at 19:30
Regular
"Devil in disguise"
Posts: 3,151
Tony D wrote:
> 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/';
Mon 05/06/06 at 13:13
Regular
Posts: 3
Garin,
you're a star. Path and permissions are now correct and it's all working. The joys of a virtual host! many thanks.
Tue 26/06/07 at 14:44
Regular
"That's 2 whole M's"
Posts: 4
Is it just me, or has this problem cropped up again. I get no error with

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?
Tue 26/06/07 at 15:06
Regular
"Devil in disguise"
Posts: 3,151
It would be helpful if you could tell us what errors you get.
Tue 26/06/07 at 15:58
Regular
"That's 2 whole M's"
Posts: 4
If I try and use file() to read the uploaded file I get the errors:


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?
Tue 26/06/07 at 18:54
Staff
Posts: 120
A number of users have brought this issue up over the last few days, I have a ticket open with our systems department asking the to investigate and resolve this issue, I believe it should be a fairly straightforward fix (adding the /var/tmp to the openbasedir restriction), and I will post when I get a response.
Thu 28/06/07 at 11:45
Staff
Posts: 120
I have now had confirmation from our systems people that this has now been resolved. My own tests confirm this, but if anyone is still experiencing issues, please place a ticket on the support system, or post here.

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Very pleased
Very pleased with the help given by your staff. They explained technical details in an easy way and were patient when providing information to a non expert like me.
Brilliant service.
Love it, love it, love it!
Christopher

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.