brandonsavage / Upload

File uploads with validation and storage strategies
MIT License
1.67k stars 315 forks source link

Runtime Exception on multiple file upload #55

Open voidabhi opened 9 years ago

voidabhi commented 9 years ago
Error
====
Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileInfo::__construct() expects parameter 1 to be string, array given' in D:\xampp\htdocs\test\Uploading\libs\vendor\codeguy\upload\src\Upload\File.php:146 Stack trace: #0 D:\xampp\htdocs\test\Uploading\libs\vendor\codeguy\upload\src\Upload\File.php(146): SplFileInfo->__construct(Array) #1 D:\xampp\htdocs\test\Uploading\upload.php(19): Upload\File->__construct('uploadFile', Object(Upload\Storage\FileSystem)) #2 {main} thrown in D:\xampp\htdocs\test\Uploading\libs\vendor\codeguy\upload\src\Upload\File.php on line 146
Frontend Code
============
<form action="upload.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td><strong>multiple Files Upload </strong></td>
</tr>
<tr>
<td>Select file 
<input name="uploadFile[]" type="file" id="ufile[]" size="50" /></td>
</tr>
<tr>
<td>Select file
<input name="uploadFile[]" type="file" id="ufile[]" size="50" /></td>
</tr>
<tr>
<td>Select file
<input name="uploadFile[]" type="file" id="ufile[]" size="50" /></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Upload" /></td>
</tr>
</table>
</td>
</form>
Backend Code
============
$storage = new \Upload\Storage\FileSystem('uploads');
$file = new \Upload\File('uploadFile',$storage);
rrrcch commented 9 years ago

I recently had the same error. The problem is that when I install the package through composer require codeguy/upload, composer is installing an old version. I checked my composer.json and the version constraint was ^1.3, which appears to not support multiple file uploads. I changed it to dev-master and it works. I'm not quite sure why this is happening, though.

khoanguyen2610 commented 6 years ago

I recently had the same error. The problem is that when I install the package through composer require codeguy/upload, composer is installing an old version. I checked my composer.json and the version constraint was ^1.3, which appears to not support multiple file uploads. I changed it to dev-master and it works. I'm not quite sure why this is happening, though.

I got same issue. Is this package still support?

stipic commented 6 years ago

@khoanguyen2610

In your composer.json

"codeguy/upload": "dev-master"

composer update

carsonlius commented 4 years ago

@stipic "dev-master" package fixed my problem ; thanks