【发布时间】:2015-06-29 17:51:58
【问题描述】:
我有一个工作 php 代码可以在数据库中上传图像。是否可以将其转换为 jquery?如果是这样,我需要做什么?我是 jquery 的新手。谢谢
这段代码工作得很好。但我需要在 jquery 中完成。
<form action = 'upload.php' method = 'post' enctype="multipart/form-data">
<input type="file" name="image" > <br>
<input type= 'submit' value = 'Add' id = 'Add' name = 'Add'>
</form>
<?php
if(isset($_FILES['image']))
{
$target_Path = "images/";
$target_Path = $target_Path.basename($_FILES['image']['name'] );
move_uploaded_file( $_FILES['image']['tmp_name'], $target_Path );
$name = $_FILES['image']['name'];
}
if(isset($_POST['Add']))
{
if($_POST["Add"] == "Add")
{
$add = "Insert Into img(path) Values('$name')";
$up = mysql_query($add);
$status = "Upload success!";
print '<script type="text/javascript">';
print 'alert(" '.$status.' ")';
print '</script>';
}
}
【问题讨论】:
-
你可以试试jquery插件。例如,Plupload plupload.com 效果很好,并且具有上传进度等简洁的功能
标签: php jquery image-uploading