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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.