我已经尝试了很多次来解决这个问题,但我无法解决它。 我也在谷歌搜索这个,但不幸的是,代码没有运行, 这是我在谷歌搜索它的示例代码。自动预览图像的Javascript或Php
<div id='preview'></div>
<form id="imageform" method="post" enctype="multipart/form-data" action='index.php'>
<input type="file" name="photoimg" id="photoimg" />
</form>
<script type ="text/javascript">
$('#photoimg').on('change', function()
{
$("#imageform").ajaxForm({target: '#preview', //Shows the response image in the div named preview
success:function(){
},
error:function(){
}
}).submit();
});
</script>
<?php
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
{
$name = $_FILES['photoimg']['name'];
$size = $_FILES['photoimg']['size'];
$tmp = $_FILES['photoimg']['tmp_name'];
$path = "uploads/";
move_uploaded_file($tmp, $path.$name); //Stores the image in the uploads folder
}
?>
你忘了问一个问题。 – 2014-12-06 01:28:03