ajax - cURL + PHP + File Upload issues -


hello fellow programmers.

i beginner programmer , have failed attempt creating script uploading image on 1 specific site.

my boss needs upload images specific site. speed things need create script that.

i use multi-part form data curl, site different.

here headers

post /upload-new.php?banner_url=http%3a%2f%2ftest.com&ad_type=1&banner_size= http/1.1 host: admin.domain.com user-agent: mozilla/5.0 (windows nt 6.1; wow64; rv:38.0) gecko/20100101 firefox/38.0 accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 accept-language: lv,en-us;q=0.7,en;q=0.3 accept-encoding: gzip, deflate content-type: application/octet-stream x-file-name: indonesia.gif x-file-size: 15450 x-file-type: image/gif x-file-date: fri, 29 may 2015 09:48:22 gmt x-requested-with: filedrop-xhr-fileapi referer: https://admin.domain.com/campaigns-edit.php content-length: 15450 cookie: goals= connection: keep-alive pragma: no-cache cache-control: no-cache gif89a,รบ http/1.1 200 ok server: nginx date: sat, 13 jun 2015 16:22:08 gmt content-type: text/html transfer-encoding: chunked connection: keep-alive vary: accept-encoding expires: thu, 19 nov 1981 08:52:00 gmt cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 pragma: no-cache content-encoding: gzip ---------------------------------------------------------- https://admin.domain.com/data/tmp-uploads/159310_20150613122208_indonesia.gif  /data/tmp-uploads/159310_20150613122208_indonesia.gif http/1.1 host: admin.domain.com user-agent: mozilla/5.0 (windows nt 6.1; wow64; rv:38.0) gecko/20100101 firefox/38.0 accept: image/png,image/*;q=0.8,*/*;q=0.5 accept-language: lv,en-us;q=0.7,en;q=0.3 accept-encoding: gzip, deflate referer: https://admin.domain.com/campaigns-edit.php cookie: goals= connection: keep-alive  http/1.1 200 ok server: nginx date: sat, 13 jun 2015 16:22:08 gmt content-type: image/gif content-length: 15450 last-modified: sat, 13 jun 2015 16:22:08 gmt connection: keep-alive etag: "557c58b0-3c5a" accept-ranges: bytes 

this tried

  $file = realpath($file_name);   $finfo = new finfo(fileinfo_mime);   $mimetype = $finfo->file($file);   $cfile = curl_file_create($file, $mimetype);      $postdata = array( '' => $cfile );    //$headers    $headers = array();    $headers[] = 'x-file-name: indonesia.gif';   $headers[] = 'x-file-size: 15450';   $headers[] = 'x-file-type: image/gif';   $headers[] = 'x-file-date: fri, 29 may 2015 09:48:22 gmt';   $headers[] = 'x-requested-with: filedrop-xhr-fileapi';      $url = "https://admin.domain.com/upload-new.php?banner_url=http%3a%2f%2ftest.com&ad_type=1&banner_size="      $ch = curl_init();       curl_setopt($ch, curlopt_url, $url);      curl_setopt($ch, curlopt_useragent, $agent);     curl_setopt($ch, curlopt_post, 1);      // curl_setopt($ch, curlopt_postfields,$postdata);      curl_setopt($ch, curlopt_returntransfer, 1);        curl_setopt($ch, curlopt_httpheader, $headers);      curl_setopt($ch, curlopt_followlocation, 1);      curl_setopt($ch, curlopt_referer, $reffer);     curl_setopt($ch, curlopt_cookiefile, $cookie_file_path);      curl_setopt($ch, curlopt_cookiejar, $cookie_file_path);                $size = filesize($lfile);         $file = fopen($lfile, 'r');      curl_setopt($ch, curlopt_postfields, "@" . $lfile);     curl_setopt($ch, curlopt_infile, $file);     curl_setopt($ch, curlopt_infilesize, $size);       if (strlen ($proxy) > 0)     {       curl_setopt($ch, curlopt_proxytype, curlproxy_http);       curl_setopt($ch, curlopt_proxy,$proxy);     }      curl_setopt($ch, curlopt_connecttimeout, 120);     curl_setopt($ch, curlopt_timeout, 120);     curl_setopt($ch, curlopt_ssl_verifypeer, false);      curl_setopt($ch, curlopt_ssl_verifyhost, 0);      $result = curl_exec($ch);       curl_close($ch); 

website answers link image gives me 404. seems failing send on file.

can please give me guidance?


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -