我有一個代碼,我正在使用爲了上傳文件。它在我上傳某些內容時正常工作,但是當我沒有上傳任何內容時,將顯示消息「內部服務器錯誤」。Internet服務器錯誤SDK解析PHP不上傳文件時
if (isset($_FILES['image'])) {
if ($_FILES['image']['size'] < 600000) {
// save file to Parse
$file = ParseFile::createFromData(
file_get_contents($_FILES['image']['tmp_name']),
$_FILES['image']['name'] );
$file->save();
} else {
echo "El archivo no se adjuntó porque rebasa el tamaño máximo permitido";
}
} else {
$file = "";
}
//The error remains if i take out this code which saves the image on the Parse database.
// So the problem is in the code above.
$report = new ParseObject("Report");
if (isset($file)) { $report->set("ImageFile", $file); }
$report->save();
喜嘗試第一行,如果(計數($ _ FILES)> 0){... }並在使用file_get_contents($ _FILES ['image'] ['tmp_name'])之前,你需要檢查文件是否存在 – volkinc
我仍然有同樣的問題 –
什麼行?錯誤應該給你錯誤行 – volkinc