这是代码:
<?php
if(isset($_POST['update']))
{
extract($_POST);
$filename = $_FILES['uni_image']['name'];
$path = "uni_banner/";
$move=move_uploaded_file($_FILES['uni_image']['tmp_name'],$path.$_FILES['uni_image']['name']);
$filename2 = $_FILES['logo']['name'];
$path2 = "uni_logo/";
$move=move_uploaded_file($_FILES['logo'['tmp_name'],$path2.$_FILES['logo']['name']);
$sql = "update all_university set university_name='$university_name',uni_type='$uni_type',short_name='$short_name',courses='$courses',address='$address',city='$city',phone='$phone',website='$website',facilities='$facilities',courses_fee='$fee',about_us='$about_us',field='$field',priority='$priority',short_name='$short_name',state='$state',form_fee='$form_fee',university_commission='$university_commission',client_commission='$client_commission',form_type='$form_type',logo='$filename2',uni_image='$filename' where university_id='".$university_id."'";
$corr=mysqli_query($link,$sql);
if ( $corr === true)
{
echo "<script type= 'text/javascript'>alert(' Record Update successfully');</script>";
}
else
{
echo "<script type= 'text/javascript'>alert('Error');</script>";
}
}
?>
<input type="file" name="logo" id="logo">
<input type="file" name="uni_image" id="uni_image">
<input type="submit" name="update" id="update">
如何在更新文件时将文件移动到文件夹中,其中$ university_id将从网址获取该文件?
谢谢
答案 0 :(得分:0)
尝试使用有效的操作和方法
在表单中使用所有输入<form action="file_path_of_upload_script.php" method="post" enctype="multipart/form-data">
<input type="file" name="logo" id="logo">
<input type="file" name="uni_image" id="uni_image">
<input type="submit" name="update" id="update">
</form>
// 并在上传过程中检查文件夹权限和有效文件夹路径..
答案 1 :(得分:0)
尝试更改此
$move=move_uploaded_file($_FILES['logo'['tmp_name'],$path2.$_FILES['logo']['name']);
<强>与强>
$move=move_uploaded_file($_FILES['logo']['tmp_name'],$path2.$_FILES['logo']['name']);
和你的html部分应该是
<form method="post" enctype="multipart/form-data">
<input type="file" name="logo" id="logo">
<input type="file" name="uni_image" id="uni_image">
<input type="submit" name="update" id="update">
</form>