Jump to content

[SOLVED] Handling PHP file uploads with FTP?


hatrickpatrick

Recommended Posts

Ok, here's the story: I'm making a form to upload a file. I haven't put in the restrictions yet, I'll do that when the form is actually working... But the problem is my php server has a file size limit, so I want to use ftp_put to move the file to another server. I tested the other server with a simple ftp_put test yesterday, so I know it works... So now, I want php to assign a random number to the end of the new filename, and send it over to the new server. It's not working though - can anyone help?

 

My code so far:

<?
if  ($submit)
{
/* connect to the server */
$filen=$FILES['file']['tmp_name'];
$rand=rand(1,1000);
$file_path="'$filen' _ '$rand'";
$conn_id = ftp_connect('ftp.hyperphp.com');
$login_result = ftp_login($conn_id, 'hp_933282', 'vse7wr');
ftp_pasv($conn_id, true);
ftp_put($conn_id, '/u2patches.hyperphp.com/htdocs/temp_files/$file_path', $file, FTP_ASCII);
echo "worked<br>";
echo "$file_path";
ftp_close($conn_id);
}
?>
<form action=ftp_test.php method=post>
<input type=file name=file><br>
<input type=submit name=submit value-=submit>
</form>

 

Sorry the code is so crude, this is just a first draft of the form, I'll add everything else in when this bit is done...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.