Helpful Information
 
 
Category: FTP Help
File manipulation: File or Ftp opinion?

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:


$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

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

$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!

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.










privacy (GDPR)