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 Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

本文將介紹七種利用免費的BingImageCreator獲得高品質輸出的方法。 BingImageCreator(現稱為MicrosoftDesigner的ImageCreator)是一個出色的線上人工智慧藝術生成器之一。它能根據使用者的提示產生高度逼真的視覺效果。提示越具體、清晰和創意,生成的效果也會更出色。 BingImageCreator在創建高品質影像方面取得了重大進展。現在它使用Dall-E3訓練模式,顯示出更高水準的細節和現實主義。然而,它能否始終如一地產生高清結果取決於幾個因素,包括快速

小米手機image怎麼刪除?在小米手機中是可以刪除image,但是多數的用戶不知道image如何的刪除,接下來就是小編為用戶帶來的小米手機image刪除方法教程,感興趣的用戶快來一起看看吧!小米手機image怎麼刪除1、先打開小米手機中的【相簿】功能;2、然後勾選不需要的圖片,點擊右下角的【刪除】按鈕;3、之後點擊最頂部的【相簿】進入到專區,選擇【回收站】;4、接著直接點選下圖所示的【清空回收站】;5、最後直接點選【永久刪除】即可完成。

LINUX是一種開源的作業系統,它的靈活性和可自訂性使得它成為了許多開發者和系統管理員的首選,在LINUX系統中,映像處理是一個非常重要的任務,而Imagemagick和Image是兩個非常受歡迎的影像處理工具,本文將為您介紹如何在Centos系統中安裝Imagemagick和Image,並提供詳細的安裝教學。 Imagemagic安裝Centos教學Imagemagick是一個功能強大的影像處理工具集,它可以在命令列下執行各種映像操作,以下是在Centos系統上安裝Imagemagick的步驟:1

imagefilledrectangle()函數繪製一個填滿矩形。語法imagefilledrectangle($img,$x1,$y1,$x2,$y2,$color)參數image 使用imagecreatetruecolor()建立空白影像。 x1點1的x座標。 y1 點1的y座標。 x2 點2的x座標。 y2 點2的y座標。 color 填滿顏色。傳回值imagefilledrectangle()函數成功返

如何使用PHP7的NameSpace和Use關鍵字組織程式碼的結構?引言:在軟體開發中,程式碼的組織結構是非常重要的,它直接關係到程式碼的可讀性、可維護性和可擴展性。隨著PHP版本的不斷迭代,PHP7引入了NameSpace和Use關鍵字,這為我們提供了更多靈活性和便利性。本文將介紹如何使用PHP7的NameSpace和Use關鍵字來組織程式碼的結構,並提供具體的代

php use類別找不到的解決方法:1、開啟對應的PHP檔案;2、將use語句插入每個檔案;3、執行「class_alias('RedBean_Facade', 'R');」程式碼即可。

如何利用PHP7的namespace和use關鍵字組織程式碼的架構?在編寫大型專案時,程式碼的結構化和組織是非常重要的。 PHP7引入了namespace和use關鍵字,幫助我們更好地管理程式碼的命名空間,提高程式碼的可讀性和可維護性。本文將介紹如何利用PHP7的namespace和use關鍵字優化程式碼結構,並附帶具體的程式碼範例。建立命名空間命名空間透過將一組相關的類

根據 Board Channels 的最新消息,Nvidia 將於 8 月 20 日開始發貨新版 GeForce RTX 4070(亞馬遜售價約 530 美元),該版本配備 GDDR6 而不是 GDDR6X 顯存。這應該允許圖表
