The filenames are resolved relative to the root folder defined in config. Change it accordingly
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
All,
So, I am working on a little project that involves some image manipulation / upload to S3 / Deletion of Local Copy, etc
Here is where I am: I can submit the file dropzone, manipulate it with intervention image, save a local copy, upload that file, persist the record. The problem comes when I try to delete the local copy. I know this code is a little sloppy for now, I am just trying to get it to work how I want before refactoring. I just have a fileupload method on my controller as shown below:
public function addPhoto($id, ImageUploadRequest $request, Factory $filesystem){
$file = $request->file('image');
$fileName = time() . $file->getClientOriginalName();
$tempFilePath = public_path('images/temp/') . $fileName;
$image = Image::make($file->getRealPath())->resize(300, null, function ($constraint) {
$constraint->aspectRatio();
})->orientate()->save($tempFilePath);
$uploadSuccess = $filesystem->put('spots-images/' . $fileName, $image->__toString(), 'public');
if($uploadSuccess):
$photo = SpotImage::create(['spot_id' => $id, 'image' => $fileName, 'image_thumbnail' => 'tn-' . $fileName]);
Storage::delete($tempFilePath); //FAILING HERE! Remove this line and everything works perfectly
return Response::json(['filename' => $fileName], 200);
endif;
}
I am getting a League\Flysystem\FileNotFoundException
It is looking for the file at the
$tempFilePath = public_path('images/temp/') . $fileName;
That is definitely where the file is located because that is where I save it to. The reason I have to save the file is because I cannot use the $filesystem->put method without saving the file (Maybe this is the real problem and I need to re-think how I am preparing the file before upload)
Anyway, any help would be greatly apprecaited.
Yups, the message is confusing. Its showing you the filename you passed it as $tempFilePath. But when its trying to delete its actually looking at home/vagrant/Sites/kiteros/storage/app/home/vagrant/Sites/kiteros/public/images/temp/1455902109deevoweb-logo.png. I recall someone else facing this problem.
Just try this out, place something as storage/app/test.png and then try deleting just by passing $tempFilePath = 'test.png'. Hope that will make sense.
Please or to participate in this conversation.