Answer the question
In order to leave comments, you need to log in
How to fix Server responded with 0 code error?
Decided to install dropzone programmatically on yii.
js code
$(function() {
var dzone = new Dropzone("#dropZed", {
paramName: "img_url",
url: "/admin/MyGallery/ImagesUpload",
method: "files",
autoProcessQueue: false,
addRemoveLinks: true,
init: function() {
var submitButton = document.querySelector("#sb-all");
dzone = this; // closure
submitButton.addEventListener("click", function() {
dzone.processQueue(); // Tell Dropzone to process all queued files.
});
}
});
Dropzone.autoDiscover = false;
});
public function actionImagesUpload(){
$model = new MyGallery;
if($_FILES['img_url']){
if($_FILES['img_url']['error'] == 0){
move_uploaded_file($_FILES['img_url']['tmp_name'],
Yii::app()->request->baseUrl . 'images/upload/' . $_FILES['img_url']['name']);
}}
$model->img_url = $_FILES['img_url']['name'];
$model->save();
}
Answer the question
In order to leave comments, you need to log in
And if so:
public function actionImagesUpload()
{
$model = new MyGallery;
if(isset($_FILES['img_url'])){
if($_FILES['img_url']['error'] == 0){
move_uploaded_file($_FILES['img_url']['tmp_name'],
Yii::app()->request->baseUrl . 'images/upload/' . $_FILES['img_url']['name']);
}
$model->img_url = $_FILES['img_url']['name'];
$model->save();
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question