Это из документации:
Код: Выделить всё
The server processes the HTTP request.
The server has to process the upload request, save the image and return a hashmap containing a link to the uploaded image. The returned hashmap needs to look like: { link: 'path_to_uploaded_file/file.png' }
Код: Выделить всё
public function froala_upload()
{
header('Content-type: application/json');
$folder = 'public/img/media';
$slika = $this->site->single_upload($folder, 'jpg|jpeg|png|bmp|JPG|JPEG|PNG|BMP');
$link = array("link" => $slika);
echo json_encode($link);
}
Код: Выделить всё
$('textarea').editable({
inlineMode: false,
imageUploadParam: "userfile",
imageUploadURL: "admin/froala_upload",
// Set the image error callback.
imageErrorCallback: function (data) {
// Bad link.
if (data.errorCode == 1) {
console.log(data);
}
// No link in upload response.
else if (data.errorCode == 2) {
console.log(data);
}
// Error during file upload.
else if (data.errorCode == 3) {
console.log(data);
}
}
});
Код: Выделить всё
Object { errorCode=1, errorStatus="Bad link."}
Код: Выделить всё
{"link":"7d59d61.jpg"}
Документация по загрузке изображений Froala
Подробнее здесь: https://stackoverflow.com/questions/217 ... n-response
Мобильная версия