开发者

my php curl upload dosn't work, display nothing?

i'm trying to test my server, and to do that,

i make a robot to upload one file (in future, i'll make it repeatedly)...

but, the upload file did not send...

here the curl

<?php
$postdata = array();
$postdata ['fieldname'] = "@/home/egy/Downloads/BIO11_0201001D.DBF";  //fieldname should be same as file input box name

$post_url = 'form-handler.php'; //url to upload file

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); 
$response = curl_exec($ch);


echo $response;
?>

and this is the handler:

<?php

if(mov开发者_JAVA百科e_uploaded_file($_FILES['fieldname']['tmp_name'], "upload"))
{
    echo "success";
}

?>

in my php, i set display_error = on and error_reporting = E_ALL

my DBF never send to server, but there is no error or warning.... am i doing wrong?

NB: Sorry for my english


This is likely becuase you need to use $_FILES['fieldname']['name'] to get what the name was in the file input box named fieldname


Did you make sure you had an enctype in your form. Mistake a lot of people make, including my self.

<form method="post" action="" enctype="multipart/form-data">


Assuming you are trying to upload a file local to the box the script is running from.. see this stackoverflow question

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜