开发者

Internal Server Error while processing the php curl code

I have a 'curl' code in php as

  $ch = curl_init("h开发者_开发知识库ttp://www.abcd.in/upload.php");
   curl_setopt($ch, CURLOPT_POSTFIELDS, array("file" => "@$file", "file_name" => "$file_name"));

   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

   curl_exec($ch);


    curl_close($ch);

the upload.php is as

 $file = $_FILES["file"]["tmp_name"];
 $file_name = $_POST["file_name"];
$file_extension = substr(strrchr($file_name, '.') , 1);

$path = "uploads/".date("YmdHis", time()).uniqid().".$file_extension";
move_uploaded_file($file, $path);

after executing this code although the image is getting uploaded,I am getting a Internal Server Error-500. How can I overcome this?


Try to see the apache log error and just verify as you installed

sudo apt-get install curl php5-curl php5-xmlrpc 


  1. This one can't work to upload anything, you forgot CURLOPT_POST.
  2. IF you're getting 500, it can't be uploaded
  3. It's target server problem when it's returning 500. Check configuration
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜