I'm facing strange problem right now - "filesize(): stat failed for C:\xampp\tmp\php7A38.tmp" exception. The problem occurs when I'm uploading files in my application built with PHP (Laravel).
Before I'm uploading the files onto the server I'm checking size of files like this (this works very well):
for ($i = 0; $i < $filesLength; $i++) {
if(filesize($request['files'][$i]) < 1572865) {
$file = $request['files'][$i];
$filename = $imageNumber.'.'.$request['files'][$i]->extension();
$file = $file->move(public_path().'/app/newsimages/'.$element->id.'/', $filename);
}
}
If I do it like that everything works very well. But the problem is that I have to put this loop in another loop, like this:
foreach($somelement as $element) {
for ($i = 0; $i < $filesLength; $i++) {
if(filesize($request['files'][$i]) < 1572865) {
$file = $request['files'][$i];
$filename = $imageNumber.'.'.$request['files'][$i]->extension();
$file = $file->move(public_path().'/app/newsimages/'.$element->id.'/', $filename);
}
}
}
In addition to that it crashes at the second loop of the foreach loop.
Maybe you have some idea what's wrong in here?