我的观点中有以下代码:
<script type="text/javascript">
$("document").ready(function(){
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("#dropzone", {
url: "{{url('subir-foto/'.$publicacion->id)}}",
maxFilesize: 10,
dictDefaultMessage : "Click aquí para subir fotos",
previewTemplate : '<div style="display:none"></div>',
});
myDropzone.on("sending", function(file) {
$("#progress").show();
$("#dropzone").hide();
});
myDropzone.on("totaluploadprogress", function(progress) {
$("#bar").width(progress+'%');
$("#percent").html(progress.toFixed(2)+'%');
if (progress==100)
$("#percent").html('Procesando...');
});
myDropzone.on("queuecomplete", function() {
$.ajax({
url: "{{URL::to('fotos/'.$publicacion->id)}}",
beforeSend: function(){$("#photos").html('<div class="spinner"></div>');},
success: function(jsonData) {
$("#photos").html(jsonData);
}
});
myDropzone.removeAllFiles(true);
$("#progress").hide();
$("#bar").width('0%');
$("#percent").html("0%");
$("#dropzone").show();
});
});
</script>
<div id="progress" style="display:none" class="progress progress-striped active">
<div id="bar" class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">
<div id="percent"></div>
</div>
</div>
<button id="dropzone" class="btn btn-primary" type="submit">Subir fotos</button>
接收图像的控制器:
public function storePhoto($id){
$publicacion = Publicacion::findOrFail($id);
//AUTENTIFICADORES DE USUARIO
if(Auth::user()->id!=$publicacion->usuario_id && Auth::user()->perfil->id!=1) return Response::view('errors.401', array(), 401);
$rules = array(
'file' => 'required|mimes:jpeg,png,gif|max:10240',
);
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()){
return Response::json($validator->messages()->first('file'), 403);
}
$articulo_id = $publicacion->articulo->id;
$file = Input::file('file');
$nuevo_nombre = sha1(time().$file->getClientOriginalName()).'.'.$file->getClientOriginalExtension();
$upload_success = $file->move(upload_path($articulo_id),$nuevo_nombre);
Image::make(upload_path($articulo_id).$nuevo_nombre)->fit(150, 100)->save(upload_path($articulo_id)."150x100_".$nuevo_nombre);
Image::make(upload_path($articulo_id).$nuevo_nombre)->resize(450, null, function ($constraint) {$constraint->aspectRatio();$constraint->upsize();})->save(upload_path($articulo_id)."450x300_".$nuevo_nombre);
$foto = new Foto;
$foto->articulo_id = $articulo_id;
$foto->nombre = $nuevo_nombre;
$foto->save();
$foto->posicion = Foto::where('articulo_id',$articulo_id)->max('posicion')+1;
$foto->save();
if( $upload_success ) {
return Response::json('success', 200);
} else {
return Response::json('error', 400);
}
}
问题是:
当我尝试上传很多照片时,我最多只能上传5张照片....在我的本地主机中使用WAMP服务器我没有这个问题。响应是500错误......
请反馈。
祝你好运
答案 0 :(得分:0)
可能是你需要增加php的执行时间。将此代码保存在您的php文件之上或更新您的php ini文件。
ini_set('max_execution_time', 300); //300 seconds = 5 minutes
您还可以增加Php 5.3.1中引入的max_file_uploads
以防万一
max_file_uploads = 100
不适用于您,然后搜索suhosin.upload.max_uploads
并将其设置为
suhosin.upload.max_uploads=100
希望这有帮助。