我正在开发一个社交website.In的用户注册页面,用户有规定添加他的照片。我做了这个与小effort.My的问题是,我想要显示的图像已经由用户上传到一个div,然后再点击表单末尾的提交按钮。我已经搜索了很多,但无法得到正确的。
我的html代码是这样的:
<img src="<?php echo $row_picture;?>" name="picture" class="settingspic" width="75" height="91" alt="profile pic" name="picture"/><a href="" onclick="return uploadimg()"> Upload</a></li>
<input type="file" name="file" id="file" style="display:none;" />我的jasvascript代码是:
function uploadimg()
{
var uploader = document.getElementById('file');
uploader.click();
return false;
}发布于 2013-01-09 14:19:17
您必须进行Ajax调用才能立即获取上传的图像。
参考URL => http://www.finalwebsites.com/demos/php_ajax_upload_example.php
发布于 2013-01-09 14:48:15
Jquery文件上传插件就是你想要的。
http://blueimp.github.com/jQuery-File-Upload/
这将会有所帮助,因为在上面的插件中,正如你所问的“在提交表单之前,你想要在div中显示图像”,这个插件是这样工作的。
试用一下
发布于 2013-01-09 14:22:45
这里有许多插件,我想它们中的大多数都会对你的项目有用。
http://www.jquery4u.com/plugins/10-jquery-ajax-file-uploader-plugins/
https://stackoverflow.com/questions/14229265
复制相似问题