As far as I’m concerned $request->file()
(returns Illuminate\Http\UploadedFile
) Laravel does not return a string, even if you look at the documentation you will notice that there is no __toString
that should be the minimum for the first to return the temporary path of the file that is uploading, see the documentation:
Then probably when passing the value to simplexml_load_file
it is searching for a file that is not the correct file, probably what is between ""
, what was trying to pass was an object, so probably:
object(Illuminate\Http\UploadedFile)#1 (0) {
}
It is very likely that the mistakes of Warning are turned off or hidden, but if turned on would display something like:
PHP Warning: simplexml_load_file() expects Parameter 1 to be a Valid path, Object Given
The phrase object given
means that it took an object, the previous sentence says, parameter 1 must be a valid path, that is, object is not path nor string.
How to read the contents of UploadedFile
of the Laravel
Probably the right thing to do UploadedFile::get()
+ simplexml_load_string()
, thus:
$xml = simplexml_load_string($request->file('publicacao')->get());
dd($xml);
According to this question, the
simplexml_load_file()
expecting afilename
, you’re passing that?– Tuxpilgrim
Yes. You have another alternative to him?
– Josivan Sousa
Put the full code snippet, including the line that returns this error, makes it easy for us to better understand the problem.
– Tuxpilgrim
$xml = simplexml_load_file($request->file('publish')); dd($xml); .
– Josivan Sousa
Put what is the content of
$request->file('publicacao')
.– Woss
No da. The file is too large. I tried to put the content in Pastebin but exceeded the maximum size.
– Josivan Sousa