File upload in UNIX

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
niekerk
Forum Newbie
Posts: 9
Joined: Fri Sep 26, 2003 11:20 am

File upload in UNIX

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

has your script (the webserver process) write permissions for upload/
User avatar
devork
Forum Contributor
Posts: 213
Joined: Fri Aug 08, 2003 6:44 am
Location: p(h) developer's network

Post by devork »

divide and conquere
execute your script step by step and check where problem is ...
niekerk
Forum Newbie
Posts: 9
Joined: Fri Sep 26, 2003 11:20 am

Post 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
niekerk
Forum Newbie
Posts: 9
Joined: Fri Sep 26, 2003 11:20 am

Post 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
Post Reply