This post is about uploading a file to server using curl. Why I'm writing this post is because of a possible bug in Postman which forced me to look for an alternative to test my upload api. Test if curl is present in system : $ which curl /usr/bin/curl If curl is not present then install it : yum (centos), apt-get (ubuntu), brew (mac) Syntax of the command : curl -F "param1=value" -F "param2=value2" -F "filecomment=file_comment" -F "image=@image_path" server_api Here's an example of the same : curl -F "user_id=12" -F "description": "desc" -F "filecomment=This is an image file" -F "image=@/Users/Desktop/testim.png" localhost:80/myblog/create If using nodeJs, you can fetch the values in fields & files parameters.
If you have basic understanding of apache, then this article is highly recommended for setup: http://httpd.apache.org/docs/1.3/howto/cgi.html I did setup this in my mac/OSx, was not easy to find info on web, hence I am briefing out the flow: 1) uncomment "LoadModule cgi_module libexec/apache2/mod_cgi.so" ( for me it exists in httpd.conf ) 2) edit virtual hosts file to look like this: ( for mac, it is in httpd-vhosts.conf ) Options Indexes MultiViews FollowSymLinks ExecCGI AllowOverride All Order allow,deny Allow from all NOTE: "/www" is where my project resides "ExecCGI" is the option that has to be there 3) Below the directory closing, add this line: ( for mac, it is in httpd-vhosts.conf ) AddHandler cgi-script cgi py 4) Restart apache: "sudo apachectl restart" Now running your project should give "End of script output before headers" error in