我正在尝试运行一个php脚本,将图像上传到我服务器上的某个位置,同时将其位置详细信息存储在我的数据库中。
一切似乎都很好,除了我的tmp_name似乎没有得到文件所以我得到的是数据库中指向我服务器中不存在的文件的字符串位置。我无法弄清楚这个。
首先这是html标记:
$imgsize=$_POST['MAX_FILE_SIZE'];
$name = $_FILES["file"]["name"];
$location = 'db/farmers_pPix/';
$load_dataFarmerPix="form/".$location.$FNAME.'_'.$LNAME.'_'.$FNO.'-'.$name;
$passport=$load_dataFarmerPix;
...
$tmp_name = $_FILES['file']['tmp_name'];
$error = $_FILES['file']['error'];
if (!empty($name)) {
move_uploaded_file($tmp_name, $load_dataFarmerPix);
if (move_uploaded_file($tmp_name, $load_dataFarmerPix)){
echo '<p style="width:100%; color:#777; font-family:eurof35-webfont;"><h4 class="text-center">Your profle has been created and photo Uploaded</h4></p>';
}
} else {
echo '<p style="width:100%; color:#777; font-family:eurof35-webfont;text-align:center;" class="text-center"><h5>please choose a file</h5></p>';
}
echo '<p style="width:100%; color:#777; font-family:eurof55-webfont;text-align:center;"><h3 class="text-center">Registration Successfull</h3></p>';
}
}
<form enctype="multipart/form-data" id="myform" class="fs-form fs-form-full" autocomplete="off" style="color:#ccc;" action="farmreg2.php" method="post">
...
<li>
<label class="fs-field-label fs-anim-upper" for="q5">Upload a Current Photo? </label>
<input class="fs-anim-lower" style="color:#ccc; padding:1%;" id="id" name="file" type="file" placeholder="Supported formats (jpg,png,bmp,gif)"/>
<input class="fs-anim-lower" id="id" value="30000" name="MAX_FILE_SIZE" type="hidden" placeholder="" required/>
</li>
...
</form>
此文件本身是farmreg2.php