LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-30-2004, 10:22 PM   #1
Sm0k3
Member
 
Registered: Sep 2003
Location: Chicago
Distribution: Slackware-current
Posts: 63

Rep: Reputation: 15
CGI in C: need assistance with file transfer


hello all,

i've got a cgi that acts as a download agent, i can't seem to figure out how to 'change' the name of the file..

example: http:/mysite/cgi-bin/download?file=file.doc

the browser (when accepting the file so i can save to disk) tries to save the file as 'download', i was wondering if there was something i could put in my code (in the server headers along with Content-Type and Content-Length) or if someone could give me an example on how to use apache's mod_rewrite (for rewriting URL's)

thanks in advance
 
Old 02-02-2004, 02:50 AM   #2
Berng
Member
 
Registered: Dec 2003
Location: Siberia,Russia
Distribution: Basically RedHat
Posts: 34

Rep: Reputation: 15
Try sending following headers:
fprintf(stdout,"Content-type: yourfiletype; name=""yourfilename""\nContent-disposition: inline; filename=""yourfilename""\n");
Best Regards,
Oleg.
 
Old 02-03-2004, 09:34 AM   #3
Sm0k3
Member
 
Registered: Sep 2003
Location: Chicago
Distribution: Slackware-current
Posts: 63

Original Poster
Rep: Reputation: 15
worked like a charm, thanks alot bro
 
Old 02-04-2004, 09:18 PM   #4
Sm0k3
Member
 
Registered: Sep 2003
Location: Chicago
Distribution: Slackware-current
Posts: 63

Original Poster
Rep: Reputation: 15
ok, i don't get this here, on my windows platform i still get the same bug, yet in linux in both netscape and konqueror, it works fine... could this be a platform specific problem?
 
Old 02-04-2004, 09:44 PM   #5
Berng
Member
 
Registered: Dec 2003
Location: Siberia,Russia
Distribution: Basically RedHat
Posts: 34

Rep: Reputation: 15
Sorry, use filename param instead of name
fprintf(stdout,"Content-type: yourfiletype; filename=""yourfilename""\nContent-disposition: inline; filename=""yourfilename""\n");
you could read this for details:

http://www.faqs.org/rfcs/rfc1895.html
Best Regards,
Oleg.
 
Old 02-04-2004, 11:14 PM   #6
Sm0k3
Member
 
Registered: Sep 2003
Location: Chicago
Distribution: Slackware-current
Posts: 63

Original Poster
Rep: Reputation: 15
aye, that worked perfectly, fenks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Assistance with extracting a series of lines from a log file katsal Linux - General 1 06-21-2005 06:55 PM
File Transfer thereeper Linux - Software 2 05-17-2005 05:26 PM
file transfer from vm phfowol Debian 3 10-23-2004 12:39 AM
need assistance with file archive complilation/cd burning issue denkenjezt Linux - General 1 10-15-2003 07:04 PM
File transfer Joe47 Linux - Newbie 2 02-09-2003 04:12 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration