I'm using laravel 4 and I installed the Intervention Image package. When I'm using it in my code whith method ->resize, ->move etc etc etc... I have this error:
Intervention Image Exception NotReadableException
Image source not readable
open: /Applications/MAMP/htdocs/myNameProject/vendor/intervention/image/src/Intervention/Image/AbstractSource.php
break;
case $this->isFilePath():
return $this->initFromPath($this->data);
break;
default:
throw new ExceptionNotReadableException("Image source not readable");
break;
}
I'm also using MAMP and Sublime Text 3 on MAC OS if it could help you.
This is my code in my controller:
public function upload() {
//***** UPLOAD FILE (on server it's an image but an Url in Database *****//
// get the input file
$file = Image::make('url_Avatar');
//set a register path to the uploaded file
$destinationPath = public_path().'upload/';
//have client extension loaded file and set a random name to the uploaded file, produce a random string of length 32 made up of alphanumeric characters [a-zA-z0-9]
$filename = $destinationPath . '' . str_random(32) . '.' . $file->getClientOriginalExtension();
//$file->move($destinationPath,$filename);
//set $file in order to resize the format and save as an url in database
$file= Image::make($image->getRealPath())->resize('200','200')->save('upload/'.$filename);
//*****VALIDATORS INPUTS and RULES*****
$inputs = Input::all();
$rules = array(
'pseudo' => 'required|between:1,64|unique:profile,pseudo',
//urlAvatar is an url in database but we register as an image on the server
'url_Avatar' => 'required|image|min:1',
);
(I don't show you the redirect of my view, but it's worked fine for this section of my controller)
here is my form code (using blade laravel template):
@extends('layout.default')
@section('title')
Name Of My Project - EditProfile
@stop
@section('content')
{{Form::open(array('url'=>'uploadAvatar','files' => true))}}
<p>
{{Form::label('pseudo','pseudo (*): ')}}
{{Form::text('pseudo',Input::old('nom'))}}
</p>
@if ($errors->has('pseudo'))
<p class='error'> {{ $errors->first('pseudo')}}</p>
@endif
<br>
<br>
<p>
{{Form::label('url_Avatar','Avatar: ')}}
{{Form::file('url_Avatar',Input::old('Url_Avatar'))}}
</p>
@if ($errors->has('url_Avatar'))
<p class='error'> {{ $errors->first('url_Avatar')}}</p>
@endif
<br>
<br>
<p>
{{Form::submit('Validate your avatar')}}
</p>
{{Form::close()}}
@stop
Of course I have installed Intervention Image package following the official website image.intervention.io/getting_started/installation (url).
How can I make my file "readable"? or resolve this error?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…