Closed datomegasherly closed 4 years ago
In Laravel, you mean that file_src_pathname
is not a string, so basically that the $file
array has something else than a string for the key name or _tmpname? If it is not a string, what is it then?
In Laravel, you mean that
file_src_pathname
is not a string, so basically that the$file
array has something else than a string for the key name or _tmpname? If it is not a string, what is it then?
It's an Illuminate\Http\UploadedFile Object
Could you provide a _vardump of the object $file
as created by Laravel, which you are using to instantiate the class?
Could you provide a _vardump of the object
$file
as created by Laravel, which you are using to instantiate the class?
sure ,
object(Illuminate\Http\UploadedFile)#265 (7) { ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> bool(false) ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(12) "13093958.jpg" ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(10) "image/jpeg" ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> int(0) ["hashName":protected]=> NULL ["pathName":"SplFileInfo":private]=> string(45) "C:\Users\Magic\AppData\Local\Temp\php6A0E.tmp" ["fileName":"SplFileInfo":private]=> string(11) "php6A0E.tmp" }
I see. So I suppose I should cast the variables from $file
into strings and integers before the class uses the array.
I see. So I suppose I should cast the variables from
$file
into strings and integers before the class uses the array.
as you wish , I just find fastest way to resolve the problem , it's maybe not the best way . as my suggested way , "strval" function will get first "SplFileInfo" from object and return current string from _file_srcpathname
Would you mind checking the code in master
? I have added a fix in commit fd5b0e6
I check that . when $file come from Laravel , in line 2210 , check that $file is array and omg! it's not an array and it's an object , and then it's not empty . after that , goes to line 2215 , and than , it has no substr (php: data: base64: ) . then it goes to line 2285 and pass the line 2299 . it's where to change ( LINE 2299 ) :
$this->file_src_pathname = (string)$file;
I check that . it's ok and uploaded successfully . at the end , thanks for your useful class
I have pushed a new version to master
. Does it work for you?
that's working good , thanks
sometimes , specially in laravel : $this->file_src_pathname , in line 2484 class.upload.php , is not string and to use mime_content_type function , we should change that to string , because of that I change line 2484 to :
$this->file_src_mime = mime_content_type(strval($this->file_src_pathname));
and it's done