I´m trying to create a way for a user to upload a file (remote) to my server. This should be a case for the ftp functions included in php, or so I thought anyway.
The user will be prompted with a form where he/she may browse their local system for a file, select it, hit the upload button and the script will take care of the rest. However, my script only works when I try it out locally. If anyone atempts the same thing remote, it produces an error. I think it has something to do with file access permissions or something. The script assumes that the file, that is to be uploaded, is on the servers harddrive, not the clients. Naturally, the server therefore can´t find the file!
Is there a way around this problem?
I´m using Apache 1.3.26, PHP 4.2.3 and WinXP.
if(!empty($_GET['upload']))
{
$ftp_server = "xxx.xxx.xxx.xxx";
$name = "aaaaa";
$pass = "bbbb";
$ftp_port = 21;
$src_file = $_GET['file'];
$dest_file = end(Explode("\",$src_file));
$conn_id =& connect($ftp_server,$ftp_port,$name,$pass);
$upload = ftp_put($conn_id, $dest_file, $src_file, FTP_BINARY);
}else{
file_form();
}
function file_form()
{
echo "
<form action='test_ftp.php' method='GET'>
<center>
<table width=400 border=1><tr><td align=center>
<h3>File:
<input type='file' name='file'>
</td></tr>
<tr><td>
<center><br><input class='button' type='submit' name='upload' value='Upload' style='width=75px' width='75px'>
</td></tr></table>
</form>
</center>";
}