[Pi3web-users] Need help with CGI with HTTP PUT method
Brought to you by:
zimpel
From: <zi...@t-...> - 2005-01-09 16:40:02
|
Hello, There's a brief description, how to handle PUT with CGI in Pi3Web, which can be found here : http://pi3web.sourceforge.net/support/howto/FileUpload.html The details depend on the programing language, which is used for CGI. A common scripting language for CGI is perl and there's also a very simple perl example : #!/usr/bin/perl if ((-e @ARGV[0]) && !(-w @ARGV[0])) { print "Content-type: text/plain\n\nPermission denied."; } else { open(FILE, "+>@ARGV[0]") || die "Can't open!"; binmode FILE; binmode STDIN; read(STDIN,$in,$ENV{CONTENT_LENGTH}); print FILE $in || die "Can't write!"; close(FILE) || die "Can't close!"; print "Content-type: text/plain\n\nUpload success."; }; Other details depend on the operating system (e.g. don't forget to switch the handle STDIN and the handle of the output file to binary mode on Win32 systems). Some things need to be taken into consideration regarding the usage scenario (if multiple users are allowed to upload files, how to handle concurrent access?). If PUT is implemented, you may need also a DELETE implementation. Finally you should think about security (user permissions, virus detection). Some of these aspects are handled in the above example script and others are handled within the server configuration. Note, that a native handler, which implements PUT requests is built in in Pi3Web. Note, that an alternative is a HTML form based upload (accordingly to RFC 1867), which uses POST request and multipart MIME messages. This is supported by most browsers (and also by a native handler in Pi3Web) and it is available as part of many scripting languages (e.g. PHP). For more complex requirements you should also think about other alternatives for content management (e.g. the XML based WEBDAV, an implementation is available for Apache). -- regards, Holger P.S.: Because I somehow didn't get the original mailing, this posting may not be assigned to the correct thread in the mailing list, sorry. |