相同的代码在laravel 4中工作,但在laravel 5中不工作。
以下是所有代码:
//Redactor Image Upload
Route::post('image/upload', function(){
$image = Input::file('file');
$filename = 'bdtimes'.rand(10, 99999999).'.'.$image->getClientOriginalExtension();
$move = Image::make($image->getRealPath())->save('uploads/images/original/'.$filename);
if($move){
return Response::json(['filelink'=>'/uploads/images/original/'. $filename]);
}else{
return Response::json(['error'=>true]);
}
});
编剧剧本:
$(function()
{
$('#redactor').redactor({
focus: true,
imageUpload: '{{ url() }}/image/upload',
imageManagerJson: '{{ url() }}/image.php',
plugins: ['table', 'video','imagemanager','fontcolor','fontsize','fullscreen'],
maxHeight: 300,
minHeight: 300
});
});
在chrome开发工具中,当我尝试上传图片时显示此错误。
Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://localhost:8000/image/upload
什么是问题?请帮帮我。
谢谢
最佳答案
更新的答案
令牌有问题。更改redactor脚本..
$(function()
{
$('#redactor').redactor({
focus: true,
imageUpload: '{{ url() }}/image/upload?_token=' + '{{ csrf_token() }}',
imageManagerJson: '{{ url() }}/image.php',
plugins: ['table', 'video','imagemanager','fontcolor','fontsize','fullscreen'],
maxHeight: 300,
minHeight: 300
});
});