Reply to Re: PHP, cURL, and File Uploads

Your name:

Reply:


Posted by Sjoerd on 06/12/06 20:52

HC wrote:
> Hi everybody :)
>
> I am trying to write a script that makes cURL submit the following form:
>
> <form method="post" action="script.php" enctype="multipart/form-data">
> <input type="file" name="somefile">
> <input type="submit" value="Send File">
> </form>
>
> I've found a few examples of how to do this, but they all require me
> creating a file first. I have the data I would like to submit in a PHP
> variable, and for security reasons, I would prefer not to write this to
> a file.
>
> If anyone has any ideas on this, that would rock all kinds of worlds.
>
> HC :)

<?php

$post_data = array();

$post_data['foo'] = "bar";
$post_data['beer'] = "good";


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://my.domain.com/my_url.php" );
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$postResult = curl_exec($ch);

if (curl_errno($ch)) {
print curl_error($ch);
}
curl_close($ch);
print "$postResult";
?>

[Back to original 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

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