我有一个简单的上传器,可以在文件夹中上传所选文件,我使用PHP,HTML和MSSQL作为我的数据库。每次成功上传文件时,弹出脚本都不起作用。什么似乎是问题?这是我的代码的一部分:
//move_uploaded_file function will upload your image. if you want to resize image before uploading see this link http://b2atutorials.blogspot.com/2013/06/how-to-upload-and-resize-image-for.html
if(move_uploaded_file($_FILES["file"]["tmp_name"],"C:\Users\Joseph\Desktop\Pics/" . $_FILES["file"]["name"]))
{
// If file has uploaded successfully, store its name in data base
$query_image = "insert into dbo.acc_images (image, status, acc_id) values ('".$_FILES['file']['name']."', 'display','')";
if(sqlsrv_query($conn, $query_image))
{
echo '<script type="text/javascript">alert("Stored in: " . "\Users\Joseph\Desktop\Pics/" . $_FILES["file"]["name"]);</script>';
}
else
{
echo 'File name not stored in database';
}
}
答案 0 :(得分:3)
你的字符串连接是错误的,它破坏了你的javascript。
试试这个:
echo '<script type="text/javascript">alert("Stored in: \Users\Joseph\Desktop\Pics/' . $_FILES["file"]["name"] . '");</script>';