Environment:
Windows 64 cURL build
C:>curl64.exe -V(ersion)
- curl 7.53.1 (x86_64-w64-mingw32) libcurl/7.53.1 WinSSL zlib/1.2.8 WinIDN libssh2/1.7.0_DEV
- Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
- Features: IDN IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL libz
My website has a PHP package for file downloads that requires an HTTP Post to specify the file to download.
When I am using a browser, I get a OPEN with/SAVE dialog and I can save the file to my computer with no problem. When I am using cURL, the requested file just streams to the console.
How do I do a cURL HTTP Post request to download a file and then save it?
- Lots of examples for uploading a file with a Post...
- Lots of examples for doing a Post in general...
- Lots of examples for simply downloading files (-O/o)...
But I can't find an example of saving the file that a Post command returns.
I've tried these three curl command lines:
C:>curl64.exe -d "download=XYZ.zip&email=&submit=Download" http://www.example.com/downloads/dl.php
C:>curl64.exe -d "download=XYZ.zip&email=&submit=Download" -O XYZ.zip http://www.example.com/downloads/dl.php
curl: Remote file name has no length!
C:>curl64.exe -d "download=XYZ.zip&email=&submit=Download" http://www.example.com/downloads/dl.php > XYZ.zip
Access is denied.
In the first two examples, the file contents are streamed to the console instead of the file being saved or giving me an option to save it.
In the third example, I tried to redirect the output, but got an "Access is denied." error. I'm a local admin on the Windows system. I've tried different directories. Still get the same error.