Asset upload with Laravel 5.5
Question
Hi, I'm using grapesjs - 0.14.15 on my server. Trying to upload images in two different ways:
assetManager: {
upload: '/uploadAsset',
assets: [],
uploadText: 'Ziehe Dateien hier her oder klicke hier.',
autoAdd: true,
addBtnText: 'ext. Bild',
modalTitle: 'Bild auswählen',
dropzone: true,
openAssetsOnDrop: true,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
and with:
assetManager: {
upload: '/uploadAsset',
assets: [],
uploadText: 'Ziehe Dateien hier her oder klicke hier.',
autoAdd: true,
addBtnText: 'ext. Bild',
modalTitle: 'Bild auswählen',
dropzone: true,
openAssetsOnDrop: true,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
uploadFile: function (e) {
var files = e.dataTransfer ? e.dataTransfer.files : e.target.files;
var formData = new FormData();
for (var i in files) {
formData.append('file-' + i, files[i]) //containing all the selected images from local
}
$.ajax({
url: '/uploadAsset',
type: 'POST',
data: formData,
contentType: false,
crossDomain: true,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
dataType: 'json',
mimeType: "multipart/form-data",
processData: false,
success: function (result) {
var myJSON = [];
$.each(result['data'], function (key, value) {
myJSON[key] = value;
});
var images = myJSON;
editor.AssetManager.add(images); //adding images to asset
}
});
}
}
In my PHP file I only want to return the files array using:
public function uploadAsset(Request $request)
{
return $request;
}
But it's allways empty. Please help - thank you. Regards Frantischek
Answers (2)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #646
Images dropped onto image picker get uploaded twice
Set the asset manager with the dropzone option set to true (which is true by default), something like that: then drop an image onto the dro...
Issue #1418
[BUG?] Asset manager not deleting files on server unless upload triggered.
Running latest version (0.14.29) on local server. Using the example webpage preset. Ubuntu 18.04, Chromium 68. Assetmanager init: And exten...
Issue #1468
[bug] modaltitle no effect
Hello, I can't translate asset manager title to french. Example : assetManager: { storageType: '', storeOnChange: true, storeAfterUpload: t...
Issue #957
[Question] Add custom attributes (data-) to assets/images on Upload/Selection
Hi, I am trying my best to find the proper/best way to do this, but I need to attach two custom HTML5 data tags to an image once it is sele...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.