나는 Fine-Uploader을 PHP와 함께 사용하고 있으며 잘못된 것이 발생했습니다. 내가 백엔드에 stream_copy_to_stream()를 사용하는 경우, 그것은 항상 0stream_copy_to_stream() 항상 0을 반환합니다.
여기 백엔드에서 내 코드의 반환
private function upload_file($file_name, $tmp_name)
{
$result = array(
'is_successful' => true,
'extra_message' => ''
);
$target_path = $this->get_target_file_path($file_name, $tmp_name);
move_uploaded_file($tmp_name, $target_path);
$result['is_successful'] = $this->handle_upload_request($target_path);
if ($result['is_successful']) {
$result['extra_message'] = $target_path;
} else {
$result['extra_message'] = 'Unknown error occured.<br />';
}
return $result;
}
private function handle_upload_request($path)
{
$input = fopen("php://input", "r");
$temp = tmpfile();
$real_size = stream_copy_to_stream($input, $temp);
fclose($input);
echo $real_size;
if ($real_size != $this->get_size()){
return false;
}
$target = fopen($path, "w");
fseek($temp, 0, SEEK_SET);
stream_copy_to_stream($temp, $target);
fclose($target);
return true;
}
그러나, 이상하게도 0으로 항상 동일한 $의 real_size, 파일을 업로드 할 수 있습니다 때로는 성공적이지만 때로는 그렇지 않습니다.
아마도 Linux의 허가 때문일 수 있습니다. 왜냐하면 파일을 업로드 할 때 파일의 mod는 644 (하지만 644이면 충분하다고 생각하기 때문입니다.) 그리고이 문제는 Windows에도 있습니다.
무엇이 문제입니까?
어떻게'$ path'가 정의 되었습니까? –
물론. 이 함수는 다른 함수에 의해 호출되며 경로는 파일을 저장할 대상 경로입니다. –
경로는 무엇입니까? –