Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

uploading files to remote ftp servers
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

Report this thread to moderator Post Follow-up to this message
Old Post
Andrew Bullock
06-04-05 08:55 PM


Re: uploading files to remote ftp servers
"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



Report this thread to moderator Post Follow-up to this message
Old Post
Kimmo Laine
06-05-05 01:55 AM


Re: uploading files to remote ftp servers
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 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

Report this thread to moderator Post Follow-up to this message
Old Post
Andrew Bullock
06-05-05 01:55 AM


Re: uploading files to remote ftp servers
"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



Report this thread to moderator Post Follow-up to this message
Old Post
Kimmo Laine
06-05-05 01:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP Language archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:46 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.