Home > Archive > PHP Language > June 2005 > uploading files to remote ftp servers
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
uploading files to remote ftp servers
|
|
| Andrew Bullock 2005-06-04, 3:55 pm |
| 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
| |
| Kimmo Laine 2005-06-04, 8:55 pm |
| "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
| |
| Andrew Bullock 2005-06-04, 8:55 pm |
| Kimmo 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 interface
> 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
| |
| Kimmo Laine 2005-06-04, 8:55 pm |
| "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
|
|
|
|
|