使用fine uploader上传文件和表单数据(一)
1在html文件中引入jquery文件和fine uploader的css及js文件
2、在html代码里加入以下一段代码作为上传文件的容器,id属性必须要有,第4步会有说明
3、在当前页面引入以下一段代码,这段代码是必须的
4、js代码,如下
5、后台代码
把文件上传后的保存地址返回到前台
整个过程大概就是这个样子,下次继续补充,会完善一些功能,如预览已上传的文件和已上传文件的删除。这篇文章除了最后提交表单的方法需要自己另写之外,其他的拿来直接用应该也是ok的。最后附上后台的uploader类
<?php
namespace Org\Uploader;
/****************************************
Example of how to use this uploader class...
You can uncomment the following lines (minus the require) to use these as your defaults.
// list of valid extensions, ex. array("jpeg", "xml", "bmp")
$allowedExtensions = array();
// max file size in bytes
$sizeLimit = 10 * 1024 * 1024;
require('fine-uploader/server/php.php');
$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
// Call handleUpload() with the name of the folder, relative to PHP's getcwd()
$result = $uploader->handleUpload('uploads/');
// to pass data through iframe you will need to encode all html tags
echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
/******************************************/
/**
* Handle file uploads via XMLHttpRequest
*/
class qqUploadedFileXhr {
/**
* Save the file to the specified path
* @return b