How to use Redactor image upload in laravel 4?
FROM?http://stackoverflow.com/questions/16736196/how-to-use-redactor-image-upload-in-laravel-4 I am trying to use Redactor with Laravel4. I can succesfully edit my textarea but I cant get to work with image uploads. When I try to upload a
FROM?http://stackoverflow.com/questions/16736196/how-to-use-redactor-image-upload-in-laravel-4
I am trying to use Redactor with Laravel4. I can succesfully edit my textarea but I cant get to work with image uploads. When I try to upload a file I get 500 error and In developer tools , I can see
Request URL:http://projemiz.dev/admin/blogs/3/postimage/3
This is my link for redactor photo upload:
$('#editor').redactor({ imageUpload: "postimage/{{$post->id}}"});
My routes are inside prefixes :
# Blog Management Route::group(array('prefix' => 'blogs'), function() { Route::get('/', array('as' => 'blogs', 'uses' => 'Controllers\Admin\BlogsController@getIndex')); Route::get('create', array('as' => 'create/blog', 'uses' => 'Controllers\Admin\BlogsController@getCreate')); Route::post('create', 'Controllers\Admin\BlogsController@postCreate'); Route::get('{blogId}/edit', array('as' => 'update/blog', 'uses' => 'Controllers\Admin\BlogsController@getEdit')); Route::post('{blogId}/edit', 'Controllers\Admin\BlogsController@postEdit'); Route::post('{blogId}/postimage','Controllers\Admin\BlogsController@postImage'); Route::get('{blogId}/delete', array('as' => 'delete/blog', 'uses' => 'Controllers\Admin\BlogsController@getDelete')); });
and my controller is :
public function postImage($blogId) { $path = base_path().'/public/uploads/img/posts/' . (int)$blogId; $image = Input::file('photo'); if (Input::hasFile('photo')) { $fileName = $file->getClientOriginalName(); $image->move($path,$fileName); $image = new Image; $image->name = $fileName.name; $image->save(); // resizing an uploaded file Image::make($image->getRealPath())->resize(300, 200)->save($path.'thumb-'.$fileName); Image::make($image->getRealPath())->resize(300, 200)->save($path.'thumb-'.$fileName); //File::delete( $path . '/' . Input::file('file.name'));*/ } }
Can anyone help me to fix my link inside redactor?
Try changing your js-script this:
$('#editor').redactor({ imageUpload: "/{{$post->id}}/postimage"});
In the upload function return the path of the image after upload
public function postImage($blogId) { $path = base_path().'/public/uploads/img/posts/' . (int)$blogId; $image = Input::file('photo'); if (Input::hasFile('photo')) { $fileName = $file->getClientOriginalName(); $image->move($path,$fileName); $image = new Image; $image->name = $fileName.name; $image->save(); // resizing an uploaded file Image::make($image->getRealPath())->resize(300, 200)->save($path.'thumb-'.$fileName); Image::make($image->getRealPath())->resize(300, 200)->save($path.'thumb-'.$fileName); // Return Image path as JSON if ($file->move($path, $fileName)) { return Response::json(array('filelink' => $path . '/' . $fileName)); } } }
原文地址:How to use Redactor image upload in laravel 4?, 感谢原作者分享。

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











PHP7의 NameSpace 및 Use 키워드를 사용하여 코드 구조를 구성하는 방법은 무엇입니까?

PHP7의 네임스페이스를 사용하고 키워드를 사용하여 코드 구조를 구성하는 방법은 무엇입니까?

GDDR6 VRAM을 탑재한 잠재적으로 더 저렴한 Nvidia GeForce RTX 4070이 8월 20일에 출시됩니다.
