【发布时间】:2018-05-27 16:51:55
【问题描述】:
我有一个带有图片上传功能的添加产品页面。 这个 sn-p 在我的视图文件中。
<div class="well">
<?php if ($modelProductitem->imagepath != '') { ?>
<div class="row oc-img-exist">
<div class="col-xs-6 col-md-4 oc-thumbs col-xs-offset-4" data-product-id="<?php echo $modelProductitem->productid; ?>">
<a href="#4" class="oc-remove-icon"><i class="fa fa-close text-danger"></i></a>
<a href="#4" class="thumbnail">
<img src="<?php echo Octopus::getImagePathProductsWeb ().'/'.$productId.'/'.$modelProductitem->imagepath; ?>" title="<?php echo $modelProductitem->imagepath; ?>">
</a>
</div>
</div>
<?php } ?>
<div class="col-md-12 drop-file dropzone oc-dropzone-previews dropzone-responsive">
x
</div>
<div class="clearfix"></div>
</div>
在我的 JS 中
productDropzone = new Dropzone ('#frm-add-product', {
url: '<?php echo Yii::app()->getBaseUrl (true); ?>/product/uploadProductImage',
acceptedFiles: '.png, .PNG, .jpeg, .JPEG, .jpg, .JPG',
autoProcessQueue: false,
addRemoveLinks: true,
uploadMultiple: true,
previewsContainer: '.oc-dropzone-previews',
clickable: '.drop-file',
init: function() {
this.on ('complete', function (file) {
if (productDropzone.getUploadingFiles ().length === 0 && productDropzone.getQueuedFiles ().length === 0) {
}
});
}
});
在我的 ProductController 中,我有这个功能:-
public function actionUploadProductImage () {
echo "test"; print_r($_POST);
die();
}
但是点击提交后dropzone js没有错误。页面只是像往常一样被重定向,就好像它根本没有通过“actionUploadProductImage”一样。
有人可以帮忙吗?谢谢
【问题讨论】:
标签: javascript php jquery yii