On Monday, 4-July-2005 at 12:28:41 SunandaDH wrote,
Thanks Sunanda, but you misunderstood me. (Not difficult to do...) The files
are on my website and I want the CGI script to provide access to them for
people to download. (I thought of this as the CGI script uploading them - the
wrong terminology to use, no doubt.) The reason for using a script instead of
providing the files directly is I want to be able to manage the number of
downloads, they being big files.
This gets close to what I want...
#!/usr/bin/rebol -cs
REBOL []
print "Content-Type: binary/octet-stream^/"
file: read/binary %path-to-file
print file
but of course PRINT corrupts the file and the name is the name of the script,
not the file.
Incidentally, the example you gave uses the read-cgi function, but it's not to
be found in the link you gave. I found it here though...
http://www.rebol.com/docs/words/wread-io.html
should anyone in the future find this thread useful.
And apologies again for sending you off on the wrong track.
-- Carl Read.
>Carl Read:
>
>> Are there examples anywhere of how to upload binary files using a CGI
>script?
>> I'd need to be able to have the file keep its real name - ie. not be given
>
>> the script name
>
>This is the way REBOL.org handles it -- we allow files to be uploaded as part
>
>of packages:
>
>Step 1 - HTML
>
>Should look something like this.....Your browser will prompt you to enter the
>
>local file name
>
><form enctype="multipart/form-data" action="your-cgi-script.r">
> <input type="file" name="file-name" size="50">
> <input type="submit" name="update" value="update">
></form>
>
>Step 2 -- multi-part decode
>
>You need Andreas' magic code for handling multi-part binary data. Get it from
>
>here:
>
>http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-message.r?m=rmlKVSQ
>
>Step 3 -- your CGI program
>
>Needs to call Andreas' function to create an object, eg
>
>post-data: read-cgi
>cgi-object: construct decode-multipart-form-data
> system/options/cgi/content-type
> copy post-data
>
>probe cgi-object ;;; to see what you got to work with.
>
>You may need to fiddle around if your form has *optional* multi-part data as
>Andreas' code will fail if none are present.
>
>You'll also need to parse the uploaded file name to get the bit you want as
>it'll be the fully-qualified path of the *local* name. Watch out for "\" in
>the
>path -- IE can send them to you...other browsers correctly give you "/"s
>
>Sunanda.
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.