Page 1 of 1

File upload in UNIX

Posted: Tue Oct 21, 2003 11:56 pm
by niekerk
I have a file upload script which i have tested in Windows. I now need to move it to my UNIX server but i am having problems with this. Here is the relevant section of the code.

Code: Select all

//absolute path on UNIX 
$uploaddir = "uploads/"; 

//full path on Windows 5.1 
//$uploaddir = 'c:\\Program Files\\Apache Group\\Apache2\\htdocs\''; 

$upfile = $uploaddir. $_FILES['userfile']['name']; 

if (!file_exists($uploaddir)){ 
        echo "upload folder does not exists"; 
      exit; 
      } 
    
if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $upfile)) { 
echo "Problem: Could not move file into directory "; 
exit; 
}


I keep getting the error message
Warning:Unable to access uploads/test.xml in /users/cam/sbscs/myusername/.public_html/cgi-bin/myphpfile.php4 on line 54
Problem: Could not move file into directory
I definitely have a directory called 'uploads' under my cgi-bin directory. Any sugestion will be appreciated.

Posted: Wed Oct 22, 2003 2:33 am
by volka
has your script (the webserver process) write permissions for upload/

Posted: Wed Oct 22, 2003 2:41 am
by devork
divide and conquere
execute your script step by step and check where problem is ...

Posted: Wed Oct 22, 2003 6:16 am
by niekerk
volka - I think the folder has write access in that i had ran the unix command "chmod 777 uploads" on it , which i believe will grant the folder read write and execute access. When i list the directory the security permission is "drwxrwxrwx".

devork - could you please suggest how i could "divide and conquer" this problem

Posted: Wed Oct 22, 2003 9:49 am
by niekerk
Desperate to resolve this problem!

I have run the

Code: Select all

getcwd()
and got
/users/cam/sbscs/myusername/.public_html/cgi-bin
as my current directory, i also used

Code: Select all

$_SERVER['DOCUMENT_ROOT']
and got
/users/csd/csd/spider/myweb
. I am not sure which one is the correct path for my upload directory please help