上传阶段完全成功没有问题。我只是不知道如何将上传的文件名存储到数据库。继承我的编码:
form.php的
<script type="text/javascript" src="js/plupload.full.js"></script>
<div id="uploader">
<p><h6><strong>Upload Files:</strong></h6></p>
<div id="filelist"></div><input type="hidden" id="hfileupload" name="hfileupload" />
<a id="pickfiles" href="javascript:;">[ Select files ]</a>
<a id="uploadfiles" href="javascript:;">[ Upload files ]</a>
<input type="hidden" id="hfilecounter" name="hfilecounter" value="0"/></div>
来自form.php的javascript
<script type="text/javascript">
//<![CDATA[
var uploader = new plupload.Uploader({
runtimes: 'flash',
flash_swf_url: 'js/plupload.flash.swf',
browse_button: 'pickfiles',
url: 'upload.php'
});
uploader.init();
uploader.bind('FilesAdded', function(up, files) {
// loop through the files array
for (var i in files) {
document.getElementById('filelist').innerHTML += '<div id="' + files[i].id + '">' + files[i].name + ' (' + plupload.formatSize(files[i].size) + ') <b></b></div>';}
});
uploader.bind('UploadProgress', function(up, file) {
document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
document.getElementById("#hfileupload").val(file.target_name+"@"+file.name);
});
uploader.bind('FileUploaded',function(up, file, Response){
if((Uploader.total.uploaded + 1) == Uploader.files.length){
var myfilename = encodeURIComponent(File.name);
};
})
uploader.bind('Error', function(up, args) {
alert(args.code + ': ' + args.message);
});
document.getElementById('uploadfiles').onclick = function() {
uploader.start();
};
//]]>
</script>
和plupload本身的默认upload.php。
我想将文件名值保存到数据库中,名为'form'的表名为'file'。