@'.'D:\images\photo-b4.jpg';
問題は、サーバー内のコードが実行されているときに、マシンからではなく、ファイルをファイリングしていることだと思います
localhostの場合と同様に、マシンとサーバーは同じであるため、物理的に場所にあるファイルを見つけます@'.'D:\images\photo-b4.jpg';
ファイルをアップロードする場合は、実行時に Web フォーム全体のリクエストを作成し、それをサーバーに投稿する必要があります。
このようなことを試してください:-それに応じて少し変更する必要がある正確なコードではありません
$requestparameters["title"] = $filetitle;
$content = file_get_contents($_FILES['uploadingfile']['tmp_name']);
$filefieldname = (array_keys($_FILES));
$delimiter = '-------------' . uniqid();
$filefields = array(
'file1' => array(
'name' => $_FILES['uploadingfile']['name'],
'type' => $_FILES['uploadingfile']['type'],
'content' => $content),
);
$data = '';
foreach ($requestparameters as $name => $value) {
$data .= "--" . $delimiter . "\r\n";
$data .= 'Content-Disposition: form-data; name="' . $name . '";' . "\r\n\r\n";
// note: double endline
$data .= $value . "\r\n";
}
foreach ($filefields as $name => $file) {
$data .= "--" . $delimiter . "\r\n";
// "filename" attribute is not essential; server-side scripts may use it
$data .= 'Content-Disposition: form-data; name="' . $filefieldname['0'] . '";' .
' filename="' . $file['name'] . '"' . "\r\n";
// this is, again, informative only; good practice to include though
$data .= 'Content-Type: ' . $file['type'] . "\r\n";
// this endline must be here to indicate end of headers
$data .= "\r\n";
// the file itself (note: there's no encoding of any kind)
$data .= $file['content'];
}
$data .= "\r\n"."--" . $delimiter . "--\r\n";
$str = $data;
// set up cURL
$ch=curl_init($url);
curl_setopt_array($ch, array(
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => array( // we need to send these two headers
'Content-Type: multipart/form-data; boundary='.$delimiter,
'Content-Length: '.strlen($str)
),
CURLOPT_POSTFIELDS => $data,
));
$ress = curl_exec($ch);
curl_close($ch);