php


Call to a member function hashName() on array Laravel 5.4


I'm trying to upload multiple images in same input and same row in the database
same way worked with me with the single image upload
but I got errors when I try it with Multiple images
here's my code :
Controller
$files = $request->file('file');
if(!empty($files)) :
foreach($files as $file) :
$name = time().$file->getClientOriginalName();
Storage::putfile('public/images', $request->file('file'));
$file->move('images/client/preview', $name);
$car->file = $name;
endforeach;
endif;
HTML
<div class="form-group {{ $errors->has('file') ? ' has-error' : '' }} ">
<input class="form-control" type="file" id="files" name="file[]" value="{{ old('file')}}" multiple />
<output id="list"></output>
#if($errors->has('file'))
<div class="alert alert-danger alert-dismissable">
<i class="fa fa-info"></i>
<b>Alert!</b> {{ $errors->first('file') }}
</div>
#endif
</div>
Here's The error :
Sorry I miss-read your question initially, don't pass request as the second argument of Storage::putfile() instead use the variable from your loop
$files = $request->file('file');
if(!empty($files)) :
foreach($files as $file) :
$name = time().$file->getClientOriginalName();
Storage::putfile('public/images', $file);
$file->move('images/client/preview', $name);
$car->file = $name;
endforeach;
endif;
The reason for the error was because the second argurment of Storage::putfile() was an array.

Related Links

OOP PHP Undefined variables and empty query
Internal Server Error / Infinite Loop with .htaccess
Swedish csv file encoding problems
Laravel query result is protected?
Why do wordpress theme loops in a single page
Routes with multiple parameters not working properly in Laravel 4?
mysql value check with next row value
Handling POST ARRAY in PHP and array_filter
getting server encountered an internal error or misconfiguration
Accessing array values using indexes in Twig
Error: Champ 'product_name' inconnu dans field list
Laravel 4.2 Eloquent Relationship with custom table name
SoapClient returning response with empty stdClass objects
how to send email from the contact form in Yii?
PHP remove hidden character from shell_exec
how to read objects in php in loop

Categories

HOME
class
mpdf
windows-8.1
activex
initialization
mathematical-optimization
gentelella
google-search-console
tfs2010
spring-security-oauth2
slide
circleci
mpu6050
dhcp
mahout-recommender
synthesis
l20n
maven-plugin
significance
adobe-illustrator
wsf
jpa-2.1
data-collection
webviewclient
network-analysis
points
gravity-forms-plugin
spring-annotations
audit
guice
toad
premake
vcenter
char-pointer
subclassing
spinner
stackpanel
cartopy
suds
jacoco-maven-plugin
newtons-method
angular-datatables
robust
type-inference
intellij-lombok-plugin
swift2.3
dynamics-crm-4
wildfly-9
nitrousio
mifos
raw-sockets
unsigned
rails-engines
frame-grab
distributed-cache
gulp-uglify
gravatar
teensy
ui4j
servicestack-bsd
gdl
lowercase
openshift-cartridge
auto-generate
extend
search-form
green-threads
fuseesb
text-align
mathematical-expressions
angular-ui-select
full-text-indexing
lumia-imaging-sdk
box2dweb
category-theory
webautomation
android-2.3-gingerbread
jini
forceclose
armv6
mft
strcmp
discovery
insertion
delphi-xe4
liveconnect
uploading
dynamic-c
upshot
jmenu
bass
rawcontacts
spring-modules
tacit-programming
webclient.uploaddata

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App