You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Medi Montaseri <me...@cybershell.com> on 2002/02/02 05:19:41 UTC

CGI Upload/download question

Hi,

I have a question regarding File Upload. My program Upload.cgi, prompt
the user
to upload a file, it then processes it and turns around and download it
by setting
the mime to a non-existing MIME type, say, "SomeCrazyType" via  header()
method.

$q->header ( -type => "application/x-SomeCrazyType" );

The problem is that if the user supplied a filename "MyFile.txt", in the
course of
returning it back to the user, and since the borwser will most likely
does not how to
deal with that crazy mime type, will prompt the user for "Save" and if
that is chosen,
then the name "Upload.cgi" is suggested.

Can I somehow influence this behavior such that the user will indeed see
something
like "MyFile.txt.returned" or "MyFile.txt.processed" in the dialog box.

By the way, the reason for the crazy MIME type, is to prevent the
browser to render it.
I'm trying to achive a complete upload-process-download. Perhaps there
is an
standard MIME type that I should use.

Thank you

--
-------------------------------------------------------------------------
Medi Montaseri                               medi@CyberShell.com
Unix Distributed Systems Engineer            HTTP://www.CyberShell.com
CyberShell Engineering
-------------------------------------------------------------------------




Re: CGI Upload/download question

Posted by Medi Montaseri <me...@cybershell.com>.
Thank you very much...worked like a charm....


Pierre Phaneuf wrote:

> Medi Montaseri wrote:
>
> > Can I somehow influence this behavior such that the user
> > will indeed see something like "MyFile.txt.returned" or
> > "MyFile.txt.processed" in the dialog box.
>
> Add a "Content-Disposition" header like this:
>
> Content-Disposition: attachment; filename=MyFile.txt.returned
>
> I don't remember for sure, but I think a Content-Length header might
> help browsers evaluate the time remaining for the download.
>
> > By the way, the reason for the crazy MIME type, is to
> > prevent the browser to render it. I'm trying to achive
> > a complete upload-process-download. Perhaps there
> > is an standard MIME type that I should use.
>
> There is a standard type for that function, application/octet-stream. Of
> course, whatever you set the Content-Type header to, Internet Explorer
> could cheerfully ignore it if the extension is associated on the client
> machine, but that's not your problem anymore I guess... ;-)
>
> --
> Pierre Phaneuf

--
-------------------------------------------------------------------------
Medi Montaseri                               medi@CyberShell.com
Unix Distributed Systems Engineer            HTTP://www.CyberShell.com
CyberShell Engineering
-------------------------------------------------------------------------




Re: CGI Upload/download question

Posted by Pierre Phaneuf <pp...@ludusdesign.com>.
Medi Montaseri wrote:

> Can I somehow influence this behavior such that the user
> will indeed see something like "MyFile.txt.returned" or
> "MyFile.txt.processed" in the dialog box.

Add a "Content-Disposition" header like this:

Content-Disposition: attachment; filename=MyFile.txt.returned

I don't remember for sure, but I think a Content-Length header might
help browsers evaluate the time remaining for the download.

> By the way, the reason for the crazy MIME type, is to
> prevent the browser to render it. I'm trying to achive
> a complete upload-process-download. Perhaps there
> is an standard MIME type that I should use.

There is a standard type for that function, application/octet-stream. Of
course, whatever you set the Content-Type header to, Internet Explorer
could cheerfully ignore it if the extension is associated on the client
machine, but that's not your problem anymore I guess... ;-)

-- 
Pierre Phaneuf