图像上传在laravel 5中不起作用
我想从管理面板添加一个产品,并显示在幼虫网站上。对于上述工作,我遵循。但在提交表单后,它会显示一个空白窗口。有人能找到这个虫子吗 产品控制器:图像上传在laravel 5中不起作用,laravel,laravel-5,Laravel,Laravel 5,我想从管理面板添加一个产品,并显示在幼虫网站上。对于上述工作,我遵循。但在提交表单后,它会显示一个空白窗口。有人能找到这个虫子吗 产品控制器: public function store(Request $request) { $image = new Image(); $this->validate($request, [ 'name' => 'required', 'price' => 'required' ]);
public function store(Request $request)
{
$image = new Image();
$this->validate($request, [
'name' => 'required',
'price' => 'required'
]);
$image->name = $request->name;
$image->description = $request->description;
$image->price = $request->price;
$image->imageurl = $request->imageurl;
if($request->hasFile('product_image')) {
$file = Input::file('product_image');
//getting timestamp
$timestamp = str_replace([' ', ':'], '-', Carbon::now()->toDateTimeString());
$name = $timestamp. '-' .$file->getClientOriginalName();
$image->filePath = $name;
$file->move(public_path().'/assets/productimage/', $name);
}
$image->save();
return redirect('admin/products');
}
Product.php(模型):
new.blade.php(视图):
Hi检查日志中的内容,并检查是否启用了调试模式(在.env中)可能发生了一些错误,您不知道itAPP_ENV=local APP_DEBUG=true APP_KEY=14890a9153e6449fae700aa5bf27f966 DB_HOST=localhost DB_DATABASE=laravel2016 DB_USERNAME=root DB_PASSWORD=''CACHE_DRIVER=file SESSION_DRIVER=file QUEUE_DRIVER=synct这是我的.ENV文件检查
storage/logs/
我在日志文件中更改了什么?
class Product extends Model
{
protected $table ='products';
protected $fillable = [
'name',
'description',
'price',
'imageurl',
'product_image'
];
}
<form class="form-horizontal form-label-left" id="multiple_upload_form" enctype="multipart/form-data" novalidate action="{{ url('/admin/product/store') }}" method="POST">
<!-- Redirect browsers with JavaScript disabled to the origin page -->
<!-- {!! csrf_field() !!} -->
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Product Title*</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="name" class="form-control col-md-7 col-xs-12" data-validate-length-range="3" name="name" placeholder="Product Title" required="required" type="text" value="" id="name">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">Description <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<textarea id="textarea" required="required" class="form-control col-md-7 col-xs-12" placeholder="Description" data-validate-length-range="10" name="description" value=""></textarea>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Original Price*</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="price" class="form-control col-md-7 col-xs-12" data-validate-length-range="1" name="price" placeholder="Original Price" required="required" type="number" value="">
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Image URL</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input id="price" class="form-control col-md-7 col-xs-12" data-validate-length-range="1" name="imageurl" placeholder="Image URL" required="required" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label" for="file">File</label>
<div class="col-md-9">
<input id="file" name="product_image" class="input-file" type="file">
</div>
</div>
<div class="item form-group">
<div class="col-md-3"></div>
<div class="col-md-2 col-sm-6 col-xs-12">
<button class="btn btn-block btn-success" type="submit">Add Product</button>
</div>
<div class="col-md-2 col-sm-6 col-xs-12">
<button class="btn btn-block btn-danger" type="reset">Cancel</button>
</div>
</div>
</form>
Route::post('/admin/product/store', 'ProductController@store');