无法更新输入类型文件值

时间:2016-07-21 22:13:40

标签: javascript php jquery html

1)我在数据库中添加图像及其标题 但是如果我第一次提交表格,那么它的工作原理会在没有选择第一次提交时预选的图像时再次显示

2)第二次提交表单将图像值设为null或为空(更新图像)

<form  method="post" enctype="multipart/form-data">
<div id="photoselect_box">
<h5 id="logo_head">Profile Image</h5>
<script>
function profile_imagee(input){
$('#profile_image')[0].src = (window.URL ? URL :webkitURL).createObjectURL(input.files[0]);
}
</script>
 //input image preview
<img src="<?php $path = "download/items/$uid/"; echo $path.$userRow['profile_image']; ?>" id="profile_image" alt="profile photo"  name="profile_image" />


<input type="file" id="img_file" name="profile_image" onChange="profile_imagee(this);"
 value="<?php echo $userRow['profile_image']; ?>" />

</div>

// i am able to update this input after clicking submit
<input type="text" id="download_content1"  name="download_content1" value="<?php echo $userRow['download_content1']; ?>" >

</form>

第二次提交表格后,我无法更新数据库中的图像值 php代码

include_once '../../database/conn.php';
$res=mysqli_query($bd,"SELECT * FROM organisation);
$userRow=mysqli_fetch_array($res); 
$email=$userRow['email'];

if (isset($_POST['register'])){


//inserting  logo  image
$profile_image=$_FILES['profile_image']['name'];
$profile_image_temp=$_FILES['profile_image']['tmp_name'];
// changing the destination required folder according to users unique id
$path = "download/items/$uid/";
@mkdir($path, 0666, true);  // Create  upload folder.
move_uploaded_file($profile_image_temp,$path.$profile_image);



 //updating image in database
 $insert="UPDATE organisation SET profile_image= '$profile_image',download_content1 = '$download_content1 '
 WHERE email = '$email'";

$insert_pro = mysqli_query($bd,$insert);
}

0 个答案:

没有答案