Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9130015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:52:41+00:00 2026-06-17T07:52:41+00:00

Hi! I’m trying automatize image uploading to a site, witch is using database to

  • 0

Hi!

I’m trying automatize image uploading to a site, witch is using database to keep track of the files. The user interface is… well, pretty crappy, and I have a lot of files. I have no access to the database, so I had to find a workaround for that and I found that I could easily mimic the site’s uploading mechanism with cURL.

I examined the POST data sent by the browser with Mozilla’s Firebug, and the source code of the site’s upload form. I was able to determine the required POST fields to be sent to the server, so I’ve put a little cURL command together in PHP.

I’m using Debian GNU/Linux, and PHP with a version number of 5.3.20-1.
The relating code looks like this:

$strfilepath = '@' .  $item->getPathname();  // get next file from directory (directory iterator)
    
$postdata = array();

$postdata['upload'] = 1;
$postdata['category_id'] = 43;
$postdata['imgtoupload'] = $strfilepath;
$postdata['actie'] = 1;
        
curl_setopt($somecurl, CURLOPT_URL, "http://some.site.at.somwhere.com/image_up.php");
curl_setopt($somecurl, CURLOPT_POST, true);
curl_setopt($somecurl, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($somecurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($somecurl, CURLOPT_NOPROGRESS, false);
curl_setopt($somecurl, CURLOPT_VERBOSE, true); // FTW!
        
$response = curl_exec($somecurl);

I want to compare the browser’s POST command to my "artifical" http request, so
my exact question is how to get the POST (or any other HTTP) request generated by cURL? (Like Firebug can do.)
The only thing I can do with curl is to enable CURLOPT_VERBOSE, but it gives back header data only.

Examining the return of the curl_getinfo() and the command line listings I found that the server gives an 302 HTTP warn, and it doesn’t upload any files:

Connection #0 to host some.site.at.somwhere.com left intact

Probably there’s some problem with authentication, but I want to make sure that the code sending the appropriate data for the server.

Thanks in advance!
Sincerely: G.

EDIT (13.01.09):

Ha! I’ve made it!
The issue was that cURL somehow overwritten the type of the sent data. It marked the image as application/octet-stream instead of image/jpeg.
I explicitly specified the type in the "file-to-be-sent" field, witch solved the problem:

 $strfilepath = '@' .  $item->getPathname() . ";type=image/jpeg" ;

It works as it should. Thanks for the help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:52:42+00:00Added an answer on June 17, 2026 at 7:52 am

    The easiest way is to use ngrep from the command line:

    ngrep -W byline host some.site.at.somwhere.com and port 80
    

    Which will dump all of the traffic to/from some.site.at.somwhere.com on port 80 to stdout. You can also have the output written to a pcap file with the -O flag:

    ngrep -O http-traffic.pcap -W byline host some.site.at.somwhere.com and port 80
    

    Some distributions don’t package ngrep in their main repositories, but tcpdump is a good alternative in that case and the syntax is similar:

    tcpdump -A -s 1600 host some.site.at.somwhere.com and port 80
    

    And to send that to a file, instead:

    tcpdump -w http-traffic.pcap -s 1600 host some.site.at.somwhere.com and port 80
    

    Note that the expression host some.site.at.somwhere.com and port 80 is the same regardless of which tool you use. You can read up on that with man pcap-filter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have thousands of HTML files to process using Groovy/Java and I need to
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am using JSon response to parse title,date content and thumbnail images and place

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.