duanmu5039 2015-08-20 13:05
浏览 40

Laravel和jquery文件上传不起作用

I'm trying to get the fileupload to work, but it doesn't work.

I get the whole time this error: Upload server currently unavailable - Thu Aug 20 2015 15:00:15 GMT+0200 (Romance (zomertijd))

And in my console this: error log

Here is my view:

<form id="fileupload" action="#" method="POST" enctype="multipart/form-data">
                        <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
                        <div class="row fileupload-buttonbar">
                            <div class="col-lg-7">
                                <!-- The fileinput-button span is used to style the file input field as button -->
                                <span class="btn green fileinput-button">
                                    <i class="fa fa-plus"></i>
                                    <span>
                                         Bestanden selecteren...
                                    </span>
                                    <input type="file" name="files[]" multiple="">
                                </span>
                                <button type="submit" class="btn blue start">
                                <i class="fa fa-upload"></i>
                                <span>
                                     Start upload
                                </span>
                                </button>
                                <button type="reset" class="btn warning cancel">
                                <i class="fa fa-ban-circle"></i>
                                <span>
                                     Annuleer upload
                                </span>
                                </button>

                                <select name="mapname">
                                    @foreach (array_reverse($folders) as $folder)
                                        <option value="$folder">{{ str_replace('-', ' ', $folder) }}</option>
                                    @endforeach
                                </select>

                                <!-- The global file processing state -->
                                <span class="fileupload-process">
                                </span>
                            </div>
                            <!-- The global progress information -->
                            <div class="col-lg-5 fileupload-progress fade">
                                <!-- The global progress bar -->
                                <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
                                    <div class="progress-bar progress-bar-success" style="width:0%;">
                                    </div>
                                </div>
                                <!-- The extended global progress information -->
                                <div class="progress-extended">
                                     &nbsp;
                                </div>
                            </div>
                        </div>
                        <!-- The table listing the files available for upload/download -->
                        <table role="presentation" class="table table-striped clearfix">
                        <tbody class="files">
                        </tbody>
                        </table>
                    </form>

Watch out, there is a change in the code! The delete button is deleted and there is code added wich ALSO must be implemented!

The images need to be uploaded to public/pictures/overall/selected mapname

If there is any more code needed, please comment it quick! I realley want to have this issue fixed.

Edit

Routes:

Route::get('img/upload', 'AdminPictureController@GetPicUpload');

(I don't upload anything yet, so there is only a get...)

Controller:

    public function postUpload(){

    $files = Input::file('files');
    $map = Input::get('mapname');

    $json = array(
        'files' => array()
        );

    foreach( $files as $file ){

        $filename = str_random(40)."_".$file->getClientOriginalName().".".$file->getClientOriginalExtension();

        $json['files'][] = array(
            'name' => $filename,
            'size' => $file->getSize(),
            'type' => $file->getMimeType(),
            'url' => '/pictures/overall/'.$map.'/'.$filename,
            //'deleteType' => 'DELETE',
            //'deleteUrl' => self::$route.'/deleteFile/'.$filename,
            );

        $upload = $file->move( public_path().'/pictures/overall/'.$map.'/', $filename );


    }

    return Response::json($json);

}

(This is the controller that has to post everything)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 一直显示正在等待HID—ISP