随机发生。我注意到它经常在第二次或第三次尝试后失败。使用$ _REQUEST似乎也不起作用。这是我的表格 -
<form method="post" action='updateImage' enctype="multipart/form-data">
<input type="hidden" name="uname" value="user">
<input type="hidden" name="image" value="photograph">
<label data-toggle="tooltip" data-placement="bottom" title="Click here to select an image">
<input type="file" name="file" accept="image/*" class="input" onchange="preview()" style="display: none;" required/>
</label>
<input type="submit" name="submit_student_photograph" value="Update Student Photograph">
</form>
编辑1:这是php脚本 -
$foldername = $this->student()->setStudentData($_POST)->setFoldername();
$filename = $foldername.'_photograph_1';
$handle = new upload($_FILES['file']);
if ($handle->uploaded) {
$handle->file_new_name_body = $filename;
$handle->image_resize = true;
$handle->image_x = 600;
$handle->image_ratio_y = true;
$handle->process('all_student_files/'.$foldername);
if ($handle->processed) {
$handle->clean();
$_SESSION['success'] = "Image has been updated.";
header("Location:?controller=students&action=showStudentProfile&uname=".$_POST['uname']."#".$_POST['direction']);
} else {
$_SESSION['error'] = "There was a problem updating the Image. Please try again!";
header("Location:?controller=students&action=showStudentProfile&uname=".$_POST['uname']."#".$_POST['direction']);
}
}
答案 0 :(得分:0)
好的,我找到了这个问题的原因! PHP设置不接受任何超过2 MB大小的文件,因此我的脚本执行失败。