我是plupluad的新手。我做了一个不错的上传器,但是当我复制到另一个页面时它不起作用。它正在使用相同的php文件进行上传。我正在检查chrome中的'network'和我的 plupload.php 说done
但是作为回应,有整个html文档,并且图片没有上传。首先,我不知道如何调试它......
这是我的HTML代码:
<?php
require_once '../../core/init.inc.php';
require_once $admin_header_path;
?>
<script src="<?php echo $site_admin_url; ?>assets/libs/plupload/plupload.full.min.js"></script>
<h1>Edit Gallery:</h1>
<?php
$galeries = new Galery();
if(isset($_GET['slug'])) {
$results = $galeries->get($_GET['slug']);
$result = $results[0];
?>
<div id="errors">
</div>
<div class="loadingmessage" id="loadingmessage">
<h1 style="color: red">WAIT...</h1>
</div>
<a id="upload_more" href="#">Upload more</a>
<div id="dialog_edit" class="dialog">
<b><a style="float: right" id="more_close" href="#">X</a></b>
<input id="upload_slug" type="hidden" name="slug" value="<?php echo $_GET['slug'] ?>"/>
<h2 style="text-align: center">Images:</h2>
<div id="upload">
<div id="plupload">
<div id="droparea">
<p>Drop files</p>
<span class="or">or</span>
<a id="browse" href="#">[Select images]</a>
</div>
<a style="border:3px solid red;padding: 3px;" href="#" id="done">DONE</a>
<div id="filelist">
</div>
</div>
</div>
</div>
<script src="<?php echo $site_admin_url; ?>galeries/js/plupload.js"></script>
<?php
} else {
} ?>
这是我的JS plupload.js文件:
var uploader = new plupload.Uploader({
runtimes : 'html5, flash',
containes: 'plupload',
browse_button: 'browse',
drop_element: "droparea",
url : '../plupload.php',
flash_swf_url : 'admin/assets/plupload/Moxie.swf',
silverlight_xap_url : 'admin/assets/plupload/Moxie.xap',
multipart: true,
urlstream_upload: true,
multipart_params: {
"slug" : $("#upload_slug").val() // HERE I AM SENDING slug TO PHP
},
max_file_size : '5mb',
resize : {width:800, height:600, quality: 90},
filters : [
{title:'Images', extensions : 'jpg,jpeg,gif,png'}
]
});
uploader.bind('UploadProgress', function(up, file) {
$("#" + file.id).find('.progress').css('width',file.percent + '%');
});
uploader.init();
uploader.bind('FilesAdded', function(up, files) {
var filelist = $("#filelist");
plupload.each(files, function(file) {
filelist.prepend('<div class="file" id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <div class="progressbar"><div class="progress"></div></div></div>');
});
$("#droparea").removeClass('hover');
uploader.start();
uploader.refresh();
});
uploader.bind("FileUploaded", function(up, file, response) {
$('#' + file.id).find('.progressbar').fadeOut();
});
uploader.bind('Error', function(up, err){
alert("\nError #" + err.code + ": " + err.message);
uploader.refresh();
});
我的plupload.php:
<?php
require_once '../../core/init.inc.php';
$db = DB::getInstance();
$slug = "none";
if(!isset($_POST['slug'])) {
$query = $db->getPDO()->prepare("SELECT slug FROM pd_galeries ORDER BY id DESC LIMIT 1");
$query->execute();
$result = $query->fetchAll(PDO::FETCH_OBJ);
$slug = $result[0]->slug;
} else {
$slug = $_POST['slug'];
}
$upload = new Upload("gallery", $_FILES['file'], $slug);
$upload->upload();
方法upload()
有效,我知道因为它适用于其他页面...