Code Comments
Programming Forum and web based access to our favorite programming groups.Hi,
How can I allow a user to upload a file to a remote ftp site?
I know how to make the file be uploaded to the same server as the php
script that I want to use, but not to a remote server. Im doing this
using the following code:
$uploaddir = realpath("upload/")."/";
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
if (move_uploaded_file($_FILES['userfile'][
'tmp_name'], $uploadfile)) {
// successful upload
}
I found this example on the net:
$file = fopen ("ftp://ftp.example.com/incoming/outputfile", "w");
if (!$file) {
echo "<p>Unable to open remote file for writing.\n";
exit;
}
/* Write the data here. */
fputs ($file, $_SERVER['HTTP_USER_AGENT'] . "\n");
fclose ($file);
but how do I modify this to "put" a file from the users HD onto the
remote ftp site?
Thanks!
Andrew
Post Follow-up to this message"Andrew Bullock" <andrewREMOVEbullockTHIS@ANDntlworldTHIS.com> kirjoitti viestissä:_Oloe.438$ls3.125@newsfe1-win.ntli.net... > Hi, > > How can I allow a user to upload a file to a remote ftp site? You let the user upload the file first to your server and store it to a temp, then you open the ftp uploader and send it there yourself, with the script you have. Use a multipart form that has a file field as an interface for the user. See handling file uploads from the manual for details. -- "I am pro death penalty. That way people learn their lesson for the next time." -- Britney Spears eternal.erectionN0@5P4Mgmail.com
Post Follow-up to this messageKimmo Laine wrote: > "Andrew Bullock" <andrewREMOVEbullockTHIS@ANDntlworldTHIS.com> kirjoitti > viestissä:_Oloe.438$ls3.125@newsfe1-win.ntli.net... > > > > > You let the user upload the file first to your server and store it to a > temp, then you open the ftp uploader and send it there yourself, with the > script you have. Use a multipart form that has a file field as an interfac e > for the user. See handling file uploads from the manual for details. > > > Do i need to remove the temp file after uploading or will a gc get it? Don't want to clog the servers tmp directory Thanks Andrew
Post Follow-up to this message"Andrew Bullock" <andrewREMOVEbullockTHIS@ANDntlworldTHIS.com> kirjoitti viestissä:H9noe.7105$iy2.3812@newsfe1-gui.ntli.net... > Kimmo Laine wrote: > > > Do i need to remove the temp file after uploading or will a gc get it? > Don't want to clog the servers tmp directory > > "The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed. " - PHP Manual, Handling File Uploads Told you to read the manual, didn't I? -- "I am pro death penalty. That way people learn their lesson for the next time." -- Britney Spears eternal.erectionN0@5P4Mgmail.com
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.