In my Laravel(v5.8.x) project, I have implemented the function of uploading images thro' CKEditor(v4.14.x).
But I want to store and fetch images from storage/wysiwyg/[AnyDir] path.
I have this code with Storage facades included:
public function upload(Request $request)
{
$destPath = storage_path() . DS . 'wysiwyg' . DS . '[AnyDir]';
if ($request->hasFile('upload')) {
$originName = $request->file('upload')->getClientOriginalName();
$fileName = pathinfo($originName, PATHINFO_FILENAME);
$extension = $request->file('upload')->getClientOriginalExtension();
$fileName = $fileName.'_'.time().'.'.$extension;
$request->file('upload')->move($destPath, $fileName);
$CKEditorFuncNum = $request->input('CKEditorFuncNum');
$url = Storage::url($fileName);
exit($url);
$msg = 'Image uploaded successfully';
$response = "<script>window.parent.CKEDITOR.tools.callFunction($CKEditorFuncNum, '$url', '$msg')</script>";
@header('Content-type: text/html; charset=utf-8');
echo $response;
}
}
But the Storage::url
method ignores the subfolders wysiwyg
and [AnyDir]
, how do I get full storage url along with subfolders in proper order ?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3euAjm0
via IFTTT
Aucun commentaire:
Enregistrer un commentaire