well, actually i want make a directoy when i chose some client on the list and he want upload the image with dropzone , so if he dont have a directory then make or if exists save the image on the own directory , well rigth now i upload the images on one directory but i want create one per user , here is my method to store, im really new on this things sorry.
thanks for your help so much.
public function store(Storage $storage, Request $request)
{
if ($request->isXmlHttpRequest() ){
$file = $request->file('file');
$timestamp = $this->getFormattedTimestamp();
$savedImgName = $this->getSavedImageName($file, $timestamp );
$imageUploaded = $this->uploadImage($file, $savedImgName, $storage);*/
if($imageUploaded){
$data = [
'original_path' => asset('/uploads/' . $savedImgName)
];
return json_encode($data, JSON_UNESCAPED_SLASHES);
}
return "uploading failed";
}
}
public function uploadImage($file, $imageFullName, $storage ){
$filesystem = new Filesystem;
return $storage->disk('file')->put($imageFullName, $filesystem->get($file) );
}
protected function getFormattedTimestamp(){
return str_replace([' ', ':'],'-', Carbon::now()->toDateTimeString() );
}
protected function getSavedImageName($file, $timestamp) {
return $timestamp.'-'.$file->getClientOriginalName();
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1rxo67G
via IFTTT
Aucun commentaire:
Enregistrer un commentaire