在字符串上调用成员函数 move()

托沃

请帮助我使用下面的代码。当我尝试上传多个图像时,我不断收到此错误“调用字符串上的成员函数 move()”。提前致谢。

这是我查看页面的代码

  {!!Form::open(['method'=>'POST','action'=>'ClientController@uploadLand','files'=>true])!!}
         {{ csrf_field() }}

          <div class="admin-form">

            <div class="row">
              <div id="maindiv">
                  <div id="formdiv">
                      <div id="filediv"><input name="file[]" type="file" id="file"/></div><br/>
                      <input type="button" id="add_more" class="upload" value="Add More Files"/>
                     <!--  <input type="submit" value="Upload File" name="submit" id="upload" class="upload"/> -->
                      <br/>
                      <br/>
                  </div>
              </div>
            </div>
  {!!Form::close()!!}

这是控制器代码

public function uploadLand(Request $request)
{
    for($i=0;$i<count($_FILES["file"]["name"]);$i++){

    $image= "";
    $file_path="images/uploads";
    $imageName = $_FILES['file']['name'][$i];
    $image->move(public_path($file_path),$imageName);
    //$image->move_uploaded_file("images/uploads".$imageName);

    }
 }
潘卡吉·马克瓦纳

试试下面的代码:

if ($request->hasFile('file')) {
    $destinationPath = 'path/th/save/file/';
    $files = $request->file('file'); // will get all files

    foreach ($files as $file) {//this statement will loop through all files.
        $file_name = $file->getClientOriginalName(); //Get file original name
        $file->move($destinationPath , $file_name); // move files to destination folder
    }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Laravel错误:在字符串上调用成员函数format()

致命错误:在字符串上调用成员函数

在null上调用成员函数move()

在字符串上调用成员函数all()(查看:

在数组上调用成员函数move()

在字符串上调用成员函数guessExtension()

Laravel 5.6:在字符串上调用成员函数getRealPath()

错误:在字符串上调用成员函数setPayrollperiodid()

在laravel中的字符串上调用成员函数latest()

在laravel中的字符串上调用成员函数format()

致命错误:在字符串上调用成员函数prepare()

错误:在字符串上调用成员函数storeAs()

在字符串上调用成员函数getRealPath()

在字符串上调用成员函数canBeViewed()

PHP:在字符串上调用成员函数contains()

在字符串上调用成员函数addEagerConstraints()

在字符串上调用成员函数notify()

致命错误:在字符串上调用成员函数Createuser

在字符串上调用成员函数fill()

在字符串上调用成员函数getRepository()

错误:在字符串上调用成员函数 addDays()

在字符串上调用成员函数 setDate()

在 Yii 的字符串上调用成员函数 saveAs()

Laravel 错误:在字符串上调用成员函数 format()

在 Laravel 的字符串上调用成员函数 has()

Laravel - 在字符串上调用成员函数 save()

上传图片时在字符串上调用成员函数 move()

Yii 2 在字符串上调用成员函数 saveAs()

Laravel:在字符串上调用成员函数 with()