我有一个问题,我想上传一张图片,但每次都会发生错误,我的$ _FILE数组为空,可能有我必须上传的文件名,但这将显示在$ _POST数组中 任何人都可以帮助我吗? 错误是在第187行的E:\ xampp \ htdocs \ StudentGuideBook \ Version1.0 \ process \ process_add_institute.php中从空值创建默认对象
private function set_instituteLogo($instituteLogo) {
if ($instituteLogo['error'] == 4) {
throw new Exception(" * File Missing");
}
**$image = getimagesize($instituteLogo['tmp_name']);**
if (!$image) {
throw new Exception(" * not a valid image");
}
if ($instituteLogo['size'] > 1000000) {
throw new Exception(" * max file size allowed is 1000 K");
}
if ($instituteLogo['type'] != "image/jpeg") {
throw new Exception(" * Only jpeg allowed");
}
if ($instituteLogo['type'] != $image['mime']) {
throw new Exception(" * Corrupt image");
}
if (is_null($this - > instituteName)) {
throw new Exception(" * Failed to generate file name");
}
$path_info = pathinfo($instituteLogo['name']);
extract($path_info);
$this - > instituteLogo = $this - > instituteName.
".".$extension;
}
private function get_instituteLogo() {
return $this - > instituteLogo;
}
public function upload_instituteLogo($soruce_path) {
$str_path = "../institutes/$this->instituteName/$this->instituteLogo";
if (!is_dir("../institutes")) {
if (!mkdir("../institutes")) {
throw new Exception(" * failed to create folder ../institutes");
}
}
if (!is_dir("../institutes/$this->instituteName")) {
if (!mkdir("../institutes/$this->instituteName")) {
throw new Exception(" * failed to create folder ../institutes/$this->instituteName");
}
}
$result = @move_uploaded_file($soruce_path, $str_path);
if (!$result) {
throw new Exception(" * Faield to uplaod file");
}
}

<div class="form-group">
<label for="focusedinput" class="col-sm-2 control-label">Institute Logo</label>
<div class="col-sm-7">
<input type="file" id="instituteLogo" name="instituteLogo">
</div>
<div class="col-sm-3">
<p class="help-block">
<?php if (isset($errors[ 'instituteLogo'])) { echo($errors[ 'instituteLogo']); } ?>
</p>
</div>
</div>
&#13;
try { $obj_user->instituteLogo = $_FILES['instituteLogo']; } catch (Exception $ex) { $errors['instituteLogo'] = $ex->getMessage(); } echo "<pre>";
print_r($_FILES);
echo "</pre>"; echo "<pre>";
print_r($_POST);
echo "</pre>";
&#13;