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?, 感谢原作者分享。

Heiße KI -Werkzeuge

Undresser.AI Undress
KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover
Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool
Ausziehbilder kostenlos

Clothoff.io
KI-Kleiderentferner

AI Hentai Generator
Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

Heiße Werkzeuge

WebStorm-Mac-Version
Nützliche JavaScript-Entwicklungstools

Herunterladen der Mac-Version des Atom-Editors
Der beliebteste Open-Source-Editor

DVWA
Damn Vulnerable Web App (DVWA) ist eine PHP/MySQL-Webanwendung, die sehr anfällig ist. Seine Hauptziele bestehen darin, Sicherheitsexperten dabei zu helfen, ihre Fähigkeiten und Tools in einem rechtlichen Umfeld zu testen, Webentwicklern dabei zu helfen, den Prozess der Sicherung von Webanwendungen besser zu verstehen, und Lehrern/Schülern dabei zu helfen, in einer Unterrichtsumgebung Webanwendungen zu lehren/lernen Sicherheit. Das Ziel von DVWA besteht darin, einige der häufigsten Web-Schwachstellen über eine einfache und unkomplizierte Benutzeroberfläche mit unterschiedlichen Schwierigkeitsgraden zu üben. Bitte beachten Sie, dass diese Software

SublimeText3 Englische Version
Empfohlen: Win-Version, unterstützt Code-Eingabeaufforderungen!

SublimeText3 Mac-Version
Codebearbeitungssoftware auf Gottesniveau (SublimeText3)