Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6357
38966 credits Members referred : 374
It's time to use PHP5!
« on: Aug 27, 2006, 08:15:43 PM »
Today I played a little bit with Curl (again)
while I have a compleet upload class sometimes I need simple upload functions in custum CMS apps.
This time I have to import a CSV file into a database and I wnat to upload the and remove the file afterwards. So I thought this must be easy with Curl, but id doesn't like this: All examples are about uploading to a remote server but is this remote also the server where the script is running? It doesn't look like...
finally I found a snippet that match a little bit like waht I need:
Code:
<?php $postData = array(); $postData[ 'file_name' ] = "@test.txt"; $postData[ 'submit' ] = "UPLOAD"; // don't know why this is here
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url ); // what is the $url its where the script is executed curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData );
$response = curl_exec( $ch );
At the end should $response holding the content of the text file, but it doesn't...
By the way this could be a good example to store uploaded data into a database...