cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: PHP cURL : File upload is sucessful in Windows but not in UNIX.

From: Morgan Galpin <morgan_at_atsourceinc.ca>
Date: Thu, 06 Dec 2007 14:23:35 -0800

Hi desai,

It seems the problem may have to do with the file / file name. I would
try the following:

   1. Make sure that when you specify $uploadFile, which appears to come
      directly from $argv[1], that you use a full case-sensitive path
      and file name. The case-sensitive part is a distinct difference
      between windows and unix.
   2. Make sure all of your path names use the forward slash, /, and not
      the backslash, \. The forward slash will work in windows and unix,
      but the backslash will only work in windows. The backslash also
      has special meaning in php "" type strings, so use the forward
      slash where you can, or if you must, escape it using two backslashes.
   3. Make sure that the file you are trying to upload is readable by
      the user that runs the php script. This may not be the problem in
      your case, but it is good to check.
   4. The file you are uploading for windows seems to be a few kilobytes
      larger than the unix one. Are they the same file? Did the unix
      version have its line endings modified from the windows version?
      Does the IIS server you are sending it to not like the unix
      version of the file? Make sure the file you are sending is in a
      format the server is expecting.

Give that a try and let us know how it goes,
Morgan Galpin.

desai shweta wrote:
>
> Hi Everyone,
>
>
>
> I am not able to Upload the file to remote server in UNIX environment.
> The same PHP-cURL script is working fine in Windows environment.
>
>
>
> I have attached my PHP script and logs with this email.
>
>
>
> First 4 screens traverse including login is working fine in both
> environment.
>
> Only uploading part is not working in UNIX.
>
>
>
> I am not sure if I am missing something. Steps of upload are written
> below.
>
>
>
> Version of PHP : 5.1.4
>
> Version of cURL: 7.15
>
>
>
>
>
> $STEPSEVENURL = 'https:\\www.PPPP.com\F\UplFile.aspx';
>
>
>
> $reffer = 'https:\\www.PPPP.com\F\UplFile.aspx';
>
>
>
> $postData = array();
>
> $postData[ '__VIEWSTATE' ] = $startposition_6;
>
> $postData[ 'Uplod' ] = $uploadFile;
>
> $postData[ 'Submit' ] = 'Submit';
>
>
>
>
>
> $ch = curl_init();
>
> curl_setopt($ch, CURLOPT_URL,$STEPSEVENURL);
>
> curl_setopt($ch, CURLOPT_VERBOSE, 1);
>
> 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_FOLLOWLOCATION, 1);
>
> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
>
> curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
>
> curl_setopt($ch, CURLOPT_REFERER, $reffer);
>
> curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
>
> curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
>
>
>
> \\output to file
>
> $fp = fopen ($step6file, 'w');
>
> curl_setopt ($ch , CURLOPT_FILE, $fp);
>
>
>
> \\execute
>
> $result =curl_exec ($ch );
>
>
>
> \\ print errors
>
> print_r(curl_getinfo($ch));
>
> echo '\n\ncURL error number:' .curl_errno($ch);
>
> echo '\n\ncURL error:' . curl_error($ch);
>
>
>
> \\close resources
>
> curl_close ($ch );
>
> fclose ($fp);
>
>
>
> Your input will be very appreciated.
>
>
>
>
>
>
>
>
>
> Thanks & Regards,
>
> SMD
>
>
>
>
> ------------------------------------------------------------------------
> Live the life in style with MSN Lifestyle. Check out! Try it now!
> <http://content.msn.co.in/Lifestyle/Default>
> ------------------------------------------------------------------------
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-12-06