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

How to retrieve SAML2 token in PHP for getting an OAuth token from WSO2 APIM
url rewrite about apache2.4.23
learning rest API in php ,trying to fetch data from table and show it using curl
Larvel Directory changing issue
How to Get Twitter Profile image using twitter API 1.1?
Swift3: HTTP POST request with parameters divided by “/”
PHP default spl autoload function do not load parent of class in namespace
Combine php syntax with ajax
Opencart language picker wierdly not working on few pages
Laravel - How to clone a relationship pivot with its attributes?
Laravel Eloquent query unexpected result
PHP or htaccess - allow external server to check if file exists
How to set values in the select dropdown box?
Getting Controller does not exist after moving my controller to sub folder in laravel 5
Mysqli Count Two Data Type in one query
Invalid argument key “nameOfTheArgument” found symfony3 (Extending an abstract service)

Categories

HOME
amazon-web-services
webview
typelite
vagrant
seedstack
paypal-ipn
dry
hdfs
openlayers-3
odata
twitter-fabric
malware
google-webmaster-tools
fogbugz
flurry
material-components
apache-kafka-connect
ipv6
tfs2010
solution
fbloginview
csrf
vimeo
complexity-theory
tomcat8
infrared
adobe-illustrator
angular2-highcharts
azure-machine-learning
coreldraw
quantitative-finance
ratio
xdebug
iwebbrowser2
bitbake
basic-authentication
copy-protection
monitor
mongodb-3.4
runtimeexception
jslint
love2d
macports
microsoft-ui-automation
xll
word-cloud
ipp-protocol
intellij-lombok-plugin
.net-micro-framework
roracle
nothing
sharpdx
karabiner
punctuation
popen
clrs
rcharts
word-2016
prefetch
yargs
okio
e
unsigned
ajaxmin
sharepoint-apps
processor
jeditable
teensy
gdl
helm
google-maps-api-2
opencyc
http.client
blank-line
roxygen2
relational-model
mathematical-expressions
debug-symbols
phonegap-facebook-plugin
juttle
ildasm
zend-mail
windows-rt
visual-c++-2012
distributed-r
.htpasswd
bittorrent-sync
wso2bam
mod-perl
django-settings
mft
mp4parser
indesign-server
blobstorage
mongo-jackson-mapper
oscilloscope
jquery-cycle
instance-variables
live-wallpaper
uitextfielddelegate
hardcode
datacontracts
asp.net-mvc-views
nsconnection
cleartype

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