You are here: Re: Revise and Repost: Question about Curl and File Uploads « PHP Programming Language « IT news, forums, messages
Re: Revise and Repost: Question about Curl and File Uploads

Posted by R. Rajesh Jeba Anbiah on 05/17/06 11:14

HC wrote:
> OK, last time I posted, I must have been totally unclear :) Hopefully
> this clears things up:
>
> I wrote the following script that uses Curl to mimic submitting a form
> over SSL with <input type='file'>. It works well, but for security
> reasons, I would like to not have to write the necessary data to a
> temporary file. If anyone could point me in the right direction, that
> would be great.
<snip>

I guess, you need to chuck CURLOPT_POST and CURLOPT_POSTFIELDS; and
hence add the file contents and other form contents explicitly via the
(custom) HTTP headers using:
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, $header_array);

To see, how to form the header manually, look at the Example section
(6) at <http://www.faqs.org/rfcs/rfc1867.html>

In other words, you need to mimic the headers of browser as long at
you're getting it done. You may also enable verbose logging for easy
debugging:

$fp_err = fopen('verbose_file.txt', 'ab+');
fwrite($fp_err, date('Y-m-d H:i:s')."\n\n"); //add timestamp to the
verbose log
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_STDERR, $fp_err);

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация