这是问题:文件名没有保存到数据库中。文件正在上传到服务器就好了,但文件名根本不会保存。文件成功上传后,我可以回显文件名,但无论出于何种原因,它确实希望将文件名保存到数据库中。我确信这是一个简单的解决方法,我只是遗漏了一些东西(我希望如此)。
提前致谢。
(ps是的,我知道我应该使用mysqli)
HTML:
<form action="" name="loa" method="post" enctype="multipart/form-data">
<input type="hidden" name="size" value="350000">
<input type="file" name="loa">
<input type="submit" name="loasub" value="Upload Letter of Authorization">
</form>
PHP:
<?php
if (!empty($_POST['loasub'])) {
$target = "loa/";
$target = $target . basename( $_FILES['loa']['name']);
$theloa = ($_FILES['loa']['name']);
mysql_connect("localhost", "user", "pass") or die(mysql_error()) ;
mysql_select_db("mydb") or die(mysql_error()) ;
//Writes the information to the database
mysql_query("UPDATE customers SET loa='$theloa' WHERE id='30'") ;
if(move_uploaded_file($_FILES['loa']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
echo $theloa;
}
else {
echo "Sorry, there was a problem uploading your file.";
}
}
?>