ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a question regarding a project that I'm working on. I'm using PERL and NET::FTP to write a small FTP web application script that will allow users on my Local Area Network to upload files to me. It will be running on my web server. I'm running RedHat Linux 9 and the Apache Web Server. I got the connection and login components working. Once the user logs into my web server using NET::FTP, I ask him to enter his local directory that contains the file he would like to upload, and the remote directory which is the destination where he wants this file to be saved on the server. I have no problem working with the remote information, but I can't seem to work with the user's local information. I am unable to retrieve any local directory information of the user due to the fact that these scripts are running off the web server. Any PWD, CWD, CHDIR that I do retrieves web server information and not local information. Is there any way to retrieve a user's local directory when he's accessing my perl script running on my web server?
I believe my problem is when I'm using the FTP PUT() function. The way I have it currently is:
$ftp->put($file);
I am only specifying the file. Maybe some sort of path is necessary? What do you think I am missing?
Thanks in advance to everyone. It is greatly appreciated.
As I understand it, you are trying to use a perl script running as a CGI program on a webserver to upload to the webserver? But you want it to upload via ftp?
i guess u cant acomplish what u intend with a cgi script. u need loacal perl scripts on the clients in the lan. on a web server u can upload files per http because this is the protocol the server understands and probably there are no ftp-servers running on the clients.
why not http?
Hello Matir, thanks for getting back to me on this.
Yes exactly, I'm trying to use a perl script running as a CGI program on a webserver to upload to the webserver. I'm using FTP via perl's NET::FTP class in order to transfer files from a local machine to the webserver. Both the local machine and webserver are running on a LAN.
However, because this perl script is running on the webserver, I am unable to retrieve any of the user's local directories that he specifies. Is there any way to retrieve local directories from a user who connects to me (the webserver) via FTP?
Hello j-ray, thanks for your reply as well.
There are FTP servers running on the clients and the webserver. How would I accomplish an upload using HTTP? Sorry I'm relatively new at perl and CGI.
Thanks Matir. So that would be the only way to do it then?
I was doing some research and came across this:
"In the line where you put the file on the ftp server, the first part should be the file on the client, and the second part should be the name of the file that will be stored on the server."
EX: $ftp->put("/home/test/abc.txt","abc.txt") ;
Do you think that would work or will the first part of the put function still refer to the file on the server?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.