I am trying to upload files from one domain to another domain for which I have used file_get_contents() function.
But I do not understand what is the problem?
Here is my code:
Warning: file_get_contents(): failed to open stream: HTTP request failed! HTTP/1.1 406 Not Acceptable in
if(isset($fileupload))
{
$postdata .= "--".MULTIPART_BOUNDARY."
".
"Content-Disposition: form-data; name=\"s_id\"
".
$_SESSION['s_id']."
";
$postdata .= "--".MULTIPART_BOUNDARY."
".
"Content-Disposition: form-data; name=\"s_deadline\"
".
$_POST['deadline']."
";
$postdata .= "--".MULTIPART_BOUNDARY."
".
"Content-Disposition: form-data; name=\"s_wordcount\"
".
$_POST['wordcount']."
";
$postdata .= "--".MULTIPART_BOUNDARY."
".
"Content-Disposition: form-data; name=\"s_subject\"
".
$_POST['subject']."
";
$postdata .= "--".MULTIPART_BOUNDARY."
".
"Content-Disposition: form-data; name=\"s_university\"
".
$_POST['university']."
";
$postdata .= "--".MULTIPART_BOUNDARY."
".
"Content-Disposition: form-data; name=\"s_notes\"
".
$_POST['notes']."
";
$postdata .= "--".MULTIPART_BOUNDARY."
".
"Content-Disposition: form-data; name=\"s_submit\"
".
"submit
";
$postdata .= "--".MULTIPART_BOUNDARY."--
";
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-Type: multipart/form-data;
boundary='.MULTIPART_BOUNDARY,
'content' => $postdata
)
);
}
else{
$postdata = http_build_query(
array(
's_id' => $_SESSION['s_id'],
's_deadline' => $_POST['deadline'],
's_wordcount' => $_POST['wordcount'],
's_subject' => $_POST['subject'],
's_university' => $_POST['university'],
's_notes' => $_POST['notes'],
's_submit' => 'submit'
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type:
application/x-www-form-urlencoded',
'content' => $postdata
)
);
}
$context = stream_context_create($opts);
$file_data = file_get_contents($remote_site.'s/create_order_test.php', false,
$context);