-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Nick Lewis wrote: > Dear Wget > > I am trying to use wget with a site that uploads a file and copies it > to the specified subdirectory but the file is not included in the > post. The command used is as follows: > > wget --post-data="directory=images" --post-file=image1.jpg > --http-user=admin --http-password=password > http://example.atltelecom.com > > The upload works ok when performed from a form in a browser so it > appears to be a wget problem
Actually, --post-file and --post-data are not intended to be used together; they both provide exactly the same functionality, which is to specify what the POST request's body content should be--in its entirety. Also, --post-file isn't intended to be used in the manner you are using it; it is meant to specify a file whose contents are in the form "key=value&key2=value2&...". This could have been made clearer in the documentation. If --post-file did work the way you are trying to use it, you'd still need some way to specify what the name of the "file upload" control was (as it appears in the HTML form). Of the two Content-Types available (application/x-www-form-urlencoded and multipart/form-data), wget currently supports only application/x-www-form-urlencoded. For submitting actual files as form content, multipart/form-data is a much more natural mechanism. You could probably still do it with application/x-www-form-urlencoded, but it would require you to translate the file contents yourself into a percent-encoded form, and place the contents as "directory=images&file=<url-encoded-file-contents>". Obviously, while this is something wget does not currently do, it is something wget ought to do. I'll look into how we might implement this in a future version. - -- Micah J. Cowan Programmer, musician, typesetting enthusiast, gamer... http://micah.cowan.name/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD4DBQFGhNCe7M8hyUobTrERCF9iAJ9w+CK/k/CKOqIbEfNSuijL+leMugCY5gnV G3pT2qz6r6qWuBGKvZ9J9A== =dKVf -----END PGP SIGNATURE-----
