我正在学习如何上传带有插入的照片。到目前为止,我已将图像上传到“照片”文件夹。这样可行。我创建了一个名为“image”的 blob 字段。
我应该看到 blob 字段中的路径还是实际照片?使困惑。
<?
$order = "INSERT INTO reg_add (connect_date,
reg,
first_name,
last_name,
image)
VALUES
('$_POST[connect_date]',
'{$_POST[reg]}nv',
'$_POST[first_name]',
'$_POST[last_name]',
'$_POST[image]')";
$new_image = 'photos/'.basename( $_FILES['image']['name']);
if(move_uploaded_file($_FILES['image']['tmp_name'], $new_image)) {
// The images was uploaded
} else{
header("location: reg_add_fail_IMAGE.php");
}
$sql = "INSERT INTO image (path) VALUES ('" . mysql_real_escape_string($path) . "')";
$result = mysql_query($order);
?>
形式:
<form id="form_register" method="POST" action="reg_add.php">
<input class="req-string bx short" type="text" name="connect_date" id="connect_date">
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
<input class="req-string bx long caps" type="text" name="reg" id="reg">
<input class="req-string bx long" type="text" name="first_name">
<input class="bx long" type="text" name="last_name">
Choose a image to upload: <input name="image" type="file">
<input id="rbSubmit" class="rb2 rbSubmit" type="submit" value="submit">
</form>