Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP upload local vs remote

Status
Not open for further replies.

partymong

Programmer
Nov 5, 2003
39
GB
Hi All,
I'm new to perl but I want to create ftp uploads for users via the web. (it has to be ftp as the files will be large)

I am using Net::FTP and the following...

$remotefile = "c:\\blah.zip";
$localfile = "blah.zip";

$ftp->put($remotefile, $localfile) or die "Cannot put file.\n";

The script looks for the file to 'put' on the web server rather than the users machine...Does anybody have any ideas why?

I have looked through the threads and haven't seemed to find a definitive answer...

If anybody has a html form/perl ftp upload example to point me in the right direction, that would be great!

Thankyou in Advance for your help!

P
 
you have a very strange syntax by calling the remotefile : localfile and vice versa. I suppose this is a result of mistyping.

Are you sure you have logged on to the ftp-server and you are in the correct directory ?
I use ftp->put($localfile,$remotefile) very often and it works ok, but maybe the localfile and remotefile are indeed mixed up in your real program.

Wim Vanherp
 
Hi Wim,
Thanks for your reply!

I have definately logged on to the ftp-server, and in the correct directory.

The file that I want to ftp gets put into the directory on the ftp server, only if the source file is on the same machine as the ftp server.

e.g. I want a remote user to upload from their c:\drive(doesn't work)
If the file is on the c:\drive of the ftp server (it does work)

I have also changed the localfile and remotefile around and the same happens...Any thoughts?

Thankyou,

Regards,

P
 
I had not read the first time that this script runs on a web server. I ahve no experience in running perlscripts on webservers but i think the way you do it is impossible because the script runs on the webserver and therefore can only see local paths (regarding to the server) and not the paths of the ftpclient. Besides it should be an enormous security bug if a script on a webserver could get a file from a visiting client. I do not know how you can do what you want but i'm pretty sure it cannot be this way, there must be some kind of dialog where the client chooses the file he wants to upload, i'm not even sure it can work.

Wim Vanherp
 
This is really webserver dependant. With Apache and Perl under UNIX you can access any file on the system. This is because UNIX relies on robust user/group permissions schemes for file access, not DocumentRoot.

I am not sure how this combination performs under windows though so in your context wimvanherp may be correct.

What webserver are you using? Apache I'd assume but tell us anyhow.
 
Appache can access any file on the system itself but not on the client that has made connection to the webserver and that is the problem of partymong, he wants an upload from a client that makes connection to his webserver

Wim Vanherp
 
I am using IIS, (Windows) and I believe Wim is right...

The script will not be able to access each users machine....

I think it may be a schoolboy error on my part...

Does anyone know of an alternative (Is it possible to use ftp url's to put files? via a browser)

Thankyou you both for your help

P


 
if you do it on client side you can use the command ftp :
f.i. : ftp -supload.txt

and in upload.txt:

open hostname
user
password
bin
lcd d:\localdirectory
put filetoupload.txt
close

but that has nothing to do with perl of course


Wim Vanherp
 
Hi,
I think you cannot actually download a file by ftp through your web browser/server but you can do it by an http upload. You can refer to this very userfull faq : faq219-406 or to this one faq219-352 (have'nt read it yet) to write an upload webpage and cgi.
Regards,
Zephan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top