";C:\xampp\tmp\phpE189.tmp“;文件不存在或不可读。在拉威尔6号
请帮帮我。 我想把图像插入文件夹,把数据插入数据库。 我尝试了很多方法,但还是失败了。 我复制了一段代码并成功运行了另一个函数 我的控制器";C:\xampp\tmp\phpE189.tmp“;文件不存在或不可读。在拉威尔6号,php,laravel,Php,Laravel,请帮帮我。 我想把图像插入文件夹,把数据插入数据库。 我尝试了很多方法,但还是失败了。 我复制了一段代码并成功运行了另一个函数 我的控制器 public function postThem(Request $req) { $this->validate($req, [ ], [ ] ); $chitiet = new chitiet()
public function postThem(Request $req) {
$this->validate($req,
[
],
[
]
);
$chitiet = new chitiet();
$chitiet->tengame=$req->tengame;
$chitiet->idnhaphathanh=$req->idnhaphathanh;
$chitiet->idtheloai=$req->idtheloai;
$chitiet->idcauhinh=$req->idcauhinh;
$chitiet->namphathanh=$req->namphathanh;
$chitiet->mota=$req->mota;
$chitiet->nentang=$req->nentang;
$chitiet->link=$req->link;
$chitiet->link2=$req->link2;
if($req->hasFile('anhbia'))
{
$file=$req->file('anhbia');
$duoi=$file->getClientOriginalExtension();
if($duoi!='jpg'){
return redirect()->back()->with('ok','Chỉ đc thêm ảnh có đuôi jpg nhé');
}
$name=$req->tengame.".jpg";
$req->file('anhbia')->move('sources/image',
$name);
$chitiet->anhbia=$name;
} else {
echo 'failese';
}
if($req->hasFile('anh1'))
{
$file=$req->file('anh1');
$duoi=$file->getClientOriginalExtension();
if($duoi!='jpg'){
return redirect()->back()->with('ok','Chỉ đc thêm ảnh có đuôi jpg nhé');
}
$name=$req->tengame."1".".jpg";
$file->move("sources/image",
$name);
$chitiet->anh1=$name;
} else {
echo 'failese';
}
if($req->hasFile('anh2'))
{
$file=$req->file('anh2');
$duoi=$file->getClientOriginalExtension();
if($duoi!='jpg'){
return redirect()->back()->with('ok','Chỉ đc thêm ảnh có đuôi jpg nhé');
}
$name=$req->tengame."2".".jpg";
$file->move("sources/image",
$name);
$chitiet->anh2=$name;
} else {
echo 'failese';
}
if($req->hasFile('anh3'))
{
$file=$req->file('anh3');
$duoi=$file->getClientOriginalExtension();
if($duoi!='jpg'){
return redirect()->back()->with('ok','Chỉ đc thêm ảnh có đuôi jpg nhé');
}
$name=$req->tengame."3".".jpg";
$file->move("sources/image",
$name);
$chitiet->anh3=$name;
} else {
echo 'failese';
}
$chitiet->video=$req->video;
$chitiet->luottai="0";
$chitiet->save();
return redirect()->back()->with('ok','Thêm game thành công :v');
我的看法
<form action="admin/chitiet/them" method="post"enctype="multipart/form-data">
@csrf
<input type="text" class="form-control" placeholder="Tên game" name="tengame" size="10" value="" require="true">
<br>
<select class="form-control match-content" name="idnhaphathanh">
@foreach($nph as $nph)
<option value="{{$nph->idnhaphathanh}}">{{$nph->tennhaphathanh}}</option>
@endforeach
</select>
<br>
<select class="form-control match-content" name="idtheloai">
@foreach($theloai as $tl)
<option value="{{$tl->idtheloai}}">{{$tl->tentheloai}}</option>
@endforeach
</select>
<br>
<select class="form-control match-content" name="idcauhinh">
@foreach($cauhinh as $ch)
<option value="{{$ch->idcauhinh}}">{{$ch->os}}, {{$ch->cpu}}, {{$ch->gpu}}, {{$ch->ram}}, {{$ch->storage}}
</option>
@endforeach
</select>
<br>
<input type="number" class="form-control" name="namphathanh" min="2000" max="2019" step="1" value="2019"
maxlength="4">
<br>
<textarea class="form-control" rows="3" placeholder="Mô tả game" name="mota"></textarea>
<br>
<select class="form-control match-content" name="nentang">
<option selected="">PC</option>
<option>Mobile</option>
</select>
<br>
<input type="text" class="form-control" placeholder="Link" size="10" value="" name="link">
<br>
<input type="text" class="form-control" placeholder="Link dự phòng" size="10" value="" name="link2">
<br>
<input type="file" class="form-control" name="anhbia" id="anhbia">
<br>
<input type="file" class="form-control" name="anh1">
<br>
<input type="file" class="form-control" name="anh2">
<br>
<input type="file" class="form-control" name="anh3">
<br>
<input type="text" class="form-control" placeholder="Video" size="10" value="" name="video">
<br>
<button type="submit" class="btn btn-success btn-block" width="30%">Thêm</button>
</form>
@csrf
@foreach($nph作为$nph)
{{$nph->tennhaphathanh}
@endforeach
@foreach($tl的贷款金额)
{{$tl->tentheloai}
@endforeach
@外汇($cauhinh as$ch)
{{$ch->os}}、{{$ch->cpu}、{{$ch->gpu}、{{$ch->ram}、{{$ch->storage}
@endforeach
个人计算机
可移动的
瑟姆
昨天,它还在工作,但现在出现了错误:
“C:\xampp\tmp\phpE189.tmp”文件不存在或不可读
我运行代码,图像被放入目录,但是数据没有,并且有一个错误。
谢谢您能显示查看文件的代码吗?您的意思是图像已成功上载到“sources/image”文件夹中?图像已成功上载,但错误仍然存在appears@BhavinThummar我已经显示查看文件注释您的代码,并向我们显示导致错误的行