我试图让文件上传工作,但它不起作用。
我得到了这个错误的全部时间:Upload server currently unavailable - Thu Aug 20 2015 15:00:15 GMT+0200 (Romance (zomertijd))
以下是我的观点:
<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">
</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>
注意,代码有变化! 删除按钮被删除,并且添加了代码,必须执行 ALSO !
图片需要上传到public/pictures/overall/
所选地图名称
如果还需要更多代码,请快速评论!我想要解决这个问题。
修改
路线:
Route::get('img/upload', 'AdminPictureController@GetPicUpload');
(我还没有上传任何内容,所以只有一个获取...)
控制器:
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);
}
(这是必须发布所有内容的控制器)