#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    46
    Rep Power
    13

    File manipulation: File or Ftp functions?


    I would like to know if it is good to use ftp connection (if the server allows) for users to upload,download and delete files, instead of file functions?

    In my case, after passing authentication through DB, php script creates userīs directory using domain ftp connection where user can store and manipulate files (in my case only .zip files) with ftp_put, ftp_get and ftp_delete.
    I made it this way simply because of security reasons because upload (copy) and delete (unlink) file functions need directory with chmod 777 to work but ftp functions works just fine with chmod 755!
    As it is necessary login and password to open ftp connection I store them outside of root directory and they are included in main script.
    My test page works fine but I would like to know can ftp file manipulation be used with various users in the same time ( probably stupid question but I have no experience in this field) , is it fast enough when there are many users and the traffic is high and generally comparation between ftp and file system manipulation?
    Like this, Ftp seems more secure then file functions.

    One question more!
    I use headers for download files displayed through loop but if I want to download directly from the link I canīt do it if the file name has spaces!?
    For example:

    PHP Code:
    $handle=opendir('path'); 
    while ((
    $file readdir($handle))!== false){ 
        if (
    $file != "." && $file != ".." && $file !=".htaccess") { 
            echo
    "<tr><td>";
            echo 
    "<a href="path/".$file$file </a>\n"
            echo
    "</td></tr>";
        } 
    }
    closedir($handle); 
    If $file is "picture.zip" no problem, it downloads like http://www.domain.com/user/picture.zip but if the file is "my picture.zip", download fails because the link is http://www.domain.com/user/my !?

    Thanks in advance
    Last edited by dado; March 23rd, 2002 at 08:23 PM.
  2. #2
  3. No Profile Picture
    Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Nov 2001
    Location
    Boston Ma.
    Posts
    1,529
    Rep Power
    0
    Hi


    encode your $file, to fill in the empty string...

    OLD FILE

    My Little Red Book .txt


    ENCODED FILE

    My%20Little%20Red%20Book%20.txt


    PHP Code:
    <?php

    $handle
    =opendir('/www/uptown/local/images'); 
    while ((
    $file readdir($handle))!== false){ 
        if (
    $file != "." && $file != ".." && $file !=".htaccess") {
            
    $label rawurlencode($file);
            echo 
    "<a href=/images/$label>$file</a><BR><BR>"
        } 
    }
    closedir($handle);

    ?>

    F!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    46
    Rep Power
    13
    Thanks Fataqui, I made mistake before and instead of rawurlencode I used urlencode and of course it didnīt work.
    Now everything is all right.

IMN logo majestic logo threadwatch logo seochat tools logo