tags:

views:

152

answers:

4

hello

i'm working on a website wherein the users can upload images (uses php 4.3.11). the files are uploaded with no problem as i can see them in the upload directory and i don't get any error message, but when i try to access the uploaded files via ftp, i get an error: no such file or directory. sometimes, i am able to access the file sometimes i get this error. what could be the problem here?

[update]
thanks for the help guys. i'm not familiar with the ftp daemon stuff. but i do access my files via ftp using FireFTP. the files are there but when try to download them or change the file properties, i get the said error. i also tried uploading a file in the folder through ftp and i was able to download it with no problem.

here is some of the code i'm working on, its kind of roundabout but i'll see on how to improve it.

my working directory is something like this www.domain.com/register/
and the upload directory is here www.domain.com/register/uploads/

users are required to register and upon sign-up, a folder is created for them in the uploads directory. i couldn't find a way to create a folder without having to be in the uploads folder itself so i redirect to a create-user-folder.php file in the uploads dir.

the file just contained this code:

    $user_foldername = rawurldecode($_GET['name']);
    mkdir($user_foldername);
    header("Location: ../form.php");     // redirect back to the page

i checked and the created folder's permission is set to 775.

and here's part of the code i use in uploading ( /register/function/function.php ):

    $path = "../uploads/$user_foldername/";
    for($j = 0; $j < $num_of_uploads; $j++){
        if(is_uploaded_file($_FILES[$file]['tmp_name'][$j])){
         $filename = $_FILES[$file]['name'][$j];
         copy($_FILES[$file]['tmp_name'][$j],$path.$filename);
        }
    }

i checked using FireFTP and the files are in the /uploads/user_foldername/ directory and its permission is set to 664. the strange thing is that when i try to download the files, at times there would be no problem at all but there are times when the error will appear.

[another update] i added chmod() after the copy() function,

    $filename = $_FILES[$file]['name'][$j];
    copy($_FILES[$file]['tmp_name'][$j],$path.$filename);
    chmod($path.$filename, 0755);

but i still get the error.

another thing is that when i access /register/uploads/user_foldername/ through the url, i can see all of the uploaded files and view them, but how is it that i can't access them via ftp?

thanks again!

A: 

This is either a permission issue, or a configuration error. Here are things you should try:

What are the permission of the uploaded files? Does the FTP user has access to these files? Have you tried logging in as the user the FTP daemon would use and see if you could read the file that way?

Do you really see the correct directory? Have you verified by putting a file in that directory yourself and downloading it? Have you used the ftp command ls to verify the presence of the folder/folders/files?

soulmerge
A: 

You might need to chmod the folder the files are in, or in some cases the files themselves. try chmoding them to 775

You can chmod files and folders through PHP it's self, with the chmod function. Or, you could use a FTP program such as filezilla.

Sam
A: 

Also check to make sure the intermediate directories are also permissioned as 755, as all the directories in the path need to be executable to be traversed.

np0x
thanks! i checked the intermediate directories, they are all set as 775, but i still can't access the files via ftp. i must be missing out on something.
kregg
A: 

i just figured out the problem. it was all because of the file name having accented characters in it, which explains why i do not always get the error message :|

<sigh> i should have seen this earlier, but anyway i hope this helps in case someone ran into the same problem.

thanks again! i really appreciate it :)

kregg
If this was truely the correct answer, you should accept it.
Kevin Peno