Page 1 of 1

uploads folder, where can i put it!

Posted: Mon Jun 28, 2004 10:31 pm
by C_Calav
hi guys,

when you upload a file and you move it from the temp folder say to a uploads folder, does the uploads folder have to be in the same dir as the upload script?

this seems to be the case for me!
i tried putting the uploads folder under page 1 and it wont work, only works when under page 2, where the upload script is.

thanx!

site
|__ Page 1
|
|
|__ Page 2/upload script, uploads

Posted: Mon Jun 28, 2004 10:50 pm
by markl999
It can be anywhere you like as long as the webserver user has permissions to write to that directory.

Posted: Mon Jun 28, 2004 10:54 pm
by C_Calav
thanx again,

thats what i thought. i have all the needed permissions and i got it working but i need the folder to be in a diff place.

ill keep timkering round with it!

thanx

Posted: Mon Jun 28, 2004 11:13 pm
by C_Calav
so having it in a diff dir branch doesnt matter?

just cant get to work eliminating problems!

does it matter if i type

/Pics/
Pics/
http://www.website.com/Pics/

Code: Select all

<?php
	move_uploaded_file($_FILES['file']['tmp_name'],
	Pics/' . $_FILES['file']['name']);
	echo 'File has been stored in your uploads directory.';
?>

Posted: Mon Jun 28, 2004 11:21 pm
by markl999

Code: Select all

move_uploaded_file($_FILES['file']['tmp_name'], '/the/full/path/to/Pics/'.$_FILES['file']['name']);

Posted: Mon Jun 28, 2004 11:33 pm
by C_Calav
ERROR:

Warning: move_uploaded_file(): open_basedir restriction in effect. File(/the/full/path/to/Pics/VVV.jpg) is not within the allowed path(s): (/var/users:/home/users:/tmp:/var/www/defaults:/usr/local/apache-custs/defaults:/usr/local/lib/php) in /var/users/modelair/modelaircraft.co.nz/htdocs/admin/insert.php on line 46
File has been stored in your uploads directory.

and heres my script...the Pics folder has full permissions

BTW it works fine when the Pics folder is in the same dir as the upload script.

Code: Select all

<?php
if (($_FILES['file']['size'] > 1000))
{
echo 'Uploading ' . $_FILES['file']['name'] . ' (' .
$_FILES['file']['type'] . ', ' .
ceil($_FILES['file']['size'] / 91024) . ' Kb).<br />';

if (file_exists('Pics/' . $_FILES['file']['name']))
{
echo $_FILES['file']['name'] . ' already exists. ';
echo 'Please delete the destination file and try again.';
}

else
{
move_uploaded_file($_FILES['file']['tmp_name'], '/the/full/path/to/Pics/'.$_FILES['file']['name']); 
echo 'File has been stored in your uploads directory.';
}

} 
?>

Posted: Mon Jun 28, 2004 11:36 pm
by markl999
File(/the/full/path/to/Pics/VVV.jpg) is not within the allowed path(s):
er...your supposed to replace /the/full/path/to/Pics with your actual full path to it. As your server has open_basedir in effect Pics will have to be in one of these directories:
/var/users:/home/users:/tmp:/var/www/defaults:/usr/local/apache-custs/defaults:/usr/local/lib/php

Posted: Mon Jun 28, 2004 11:40 pm
by C_Calav
whoops! silly me! sorry

i get ya, but where are these directories?

/var/users:/home/users:/tmp:/var/www/defaults:/usr/local/apache-custs/defaults:/usr/local/lib/php

what would be an example?

thanx for all ur help and putting up with me this is very confusing for me

Posted: Mon Jun 28, 2004 11:43 pm
by markl999
ok, i'd just create a directory called Pics in your document root, that's the directory your index.php file is in.
Then use :
move_uploaded_file($_FILES['file']['tmp_name'], $_SERVER['DOCUMENT_ROOT'].'/Pics/'.$_FILES['file']['name']);

Make sure the Pics directory has sufficient permissions.

Posted: Mon Jun 28, 2004 11:51 pm
by C_Calav
Warning: move_uploaded_file(): open_basedir restriction in effect. File(/etc/httpd/htdocs/Pics/GAG.jpg) is not within the allowed path(s): (/var/users:/home/users:/tmp:/var/www/defaults:/usr/local/apache-custs/defaults:/usr/local/lib/php) in /var/users/modelair/modelaircraft.co.nz/htdocs/admin/insert.php on line 38
File has been stored in your uploads directory.

still getting a error

Posted: Tue Jun 29, 2004 12:03 am
by markl999
Looks like the host has some funky symlinking going on (stooopid open_basedir).
So try:
move_uploaded_file($_FILES['file']['tmp_name'], '/var/users/modelair/modelaircraft.co.nz/htdocs/Pics/'.$_FILES['file']['name']);

(presuming you created the Pics dir in /var/users/modelair/modelaircraft.co.nz/htdocs/)

Posted: Tue Jun 29, 2004 12:14 am
by C_Calav
that did it! thanx you very much for your help today :D

Posted: Tue Jun 29, 2004 12:16 am
by markl999
No problem, glad you got it to work ;)