Try adding
'X-Requested-With': 'XMLHttpRequest',
to your headers
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am not sure what is wrong here, of course all works outside laravel (php) but not with laravel8. all the time I have below error
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
The GET method is not supported for this route. Supported methods: POST.
sample code comes from js.devexpress.com/Demos/WidgetsGallery/Demo/FileUploader/ChunkUploading/jQuery/Light/
my route are cnfigured as below
Route::get('drop', 'App\Http\Controllers\GalleryController@drop');
Route::post('dropupload', 'App\Http\Controllers\GalleryController@dropupload');
Blade
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<link rel="stylesheet" href="https://cdn3.devexpress.com/jslib/21.2.7/css/dx.light.css">
<script type="text/javascript" src="https://cdn3.devexpress.com/jslib/21.2.7/js/dx.all.js"></script>
</head>
<div class="dx-viewport ">
<div class="demo-container">
<div id="file-uploader"></div>
<span class="note">Maximum file size: <span>4 MB.</span></span>
<div class="chunk-panel"> </div>
</div>
</div>
<script>
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$(() => {
$('#file-uploader').dxFileUploader({
name: 'file',
multiple: true,
accept: 'image/*',
chunkSize: 2000000,
method: 'POST',
type: 'POST',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
uploadMode: 'instantly',
uploadUrl: '/dropupload',
onProgress: onUploadProgress,
});
});
function onUploadStarted() {
getChunkPanel().innerHTML = '';
}
function onUploadProgress(e) {
getChunkPanel().appendChild(addChunkInfo(e.segmentSize, e.bytesLoaded, e.bytesTotal));
}
function addChunkInfo(segmentSize, loaded, total) {
const result = document.createElement('DIV');
result.appendChild(createSpan('Chunk size:'));
result.appendChild(createSpan(getValueInKb(segmentSize), 'segment-size'));
result.appendChild(createSpan(', Uploaded:'));
result.appendChild(createSpan(getValueInKb(loaded), 'loaded-size'));
result.appendChild(createSpan('/'));
result.appendChild(createSpan(getValueInKb(total), 'total-size'));
return result;
}
function getValueInKb(value) {
return `${(value / 1024).toFixed(0)}kb`;
}
function createSpan(text, className) {
const result = document.createElement('SPAN');
if (className) { result.className = `${className} dx-theme-accent-as-text-color`; }
result.innerText = text;
return result;
}
function getChunkPanel() {
return document.querySelector('.chunk-panel');
}
</script>
I have this same errror for type/method POST or GET
I am not sure if this is related but also i have below exception
CSRF token mismatch.
C:\wamp\www\asystentfotografa.dev\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php#85
Illuminate\Session\TokenMismatchException
});
}
throw new TokenMismatchException('CSRF token mismatch.');
}
/**
Please or to participate in this conversation.