Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Perl CGI to download files via web browser

by marto (Cardinal)
on Mar 08, 2013 at 13:47 UTC ( [id://1022422]=note: print w/replies, xml ) Need Help??


in reply to Perl CGI to download files via web browser

You mean the part you're stuck on is where you upload the file from a client machine back to the server? Your question could use some clarification, and you could show us the code you're actually working on/having problems with, How do I post a question effectively?.

  • Comment on Re: Perl CGI to download files via web browser

Replies are listed 'Best First'.
Re^2: Perl CGI to download files via web browser
by tanuj (Novice) on Mar 08, 2013 at 13:55 UTC
    Thanks for the reply. there are three steps : 1. upload a file from my machine ( client ) to server machine using CGI -> i am done with this part. 2. convert the uploaded file to the required format -> i am done with this part too. 3. Now the converted file is under some dir of server machine , now i want to get ( downlaod ) this file back to may local machine ( client ) -> i am stuck in this part.

      One solution would be to load the file contents into memory and serve the content with the appropriate header. This of course depends on the size of the file, you don't want to load large files into memory and serve it like this. You could copy the file into a temporary web accessable area and provide a link to it.

      Other things to consider, do you want to remove the converted file after you've sered it, so that you don't end up filling some filesystem with old files people have downloaded? Perhaps you'd need to write a housekeeping script to tidy up these files/areas on a regular basis. Clarify your requirements and consider the implications of your system. See also Print to Browser Headers Not Working Serve a file from a CGI script.

        i was trying with the below code:
        #!/usr/bin/perl #print "Content-type: text/html\n\n"; my $filepath='/upload/testing.pm'; print "Content-Type: text/html\n\n"; open("DOWNLOADFILE", "<".$filePath); while($fileContents = <DOWNLOADFILE>) { print $fileContents; } print "Content-Type: text\n"; print "Content-Disposition: attachement; filename='testing.pm'\n"; print "Content-Description: File to download\n\n"; close DOWNLOADFILE;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1022422]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-23 21:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found