php - 将文件夹移动到不同的文件夹会在 xampp 中找不到错误页面
问题描述
我在文件夹“htdocs/webdev/example”中有一个 laravel 项目,我将整个“example”文件夹复制到另一个文件夹“htdocs/Webeng”,因为该示例文件夹不起作用,它显示第一个视图但在表单提交它说“找不到页面”但是使用工匠服务可以提供正确的输出
showForm.blade.php
<!-- showForm.blade.php -->
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Upload File</title>
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-12">
<br><br><br>
<!-- store route as action -->
<form action="{{route('uploads')}}" method="post" enctype="multipart/form-data">
@csrf
<!-- value Part -->
<input type="file" class="form-control" name="thing" id="title">
<br>
<input type="submit" class="btn btn-sm btn-block btn-danger" value="Upload" onclick="spinner()">
</form>
@if (session('message'))
<h1 id="t">{{ session('message') }}</h1>
@endif
</div>
</div>
</div>
</body>
</html>
网页.php
<?php
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('showForm');
})->name("start");
Route::post('/uploads', function (Request $request) {
if($request->file("thing")=="")
{
// return back()->withInput();
return redirect()->route('start')->with('message', 'Insert Data!');
}
else
{
$name=$request->file("thing")->getClientOriginalName();
$book=DB::table('books')->where('Title',$name)->count();
if($book>0)
{
return redirect()->route('start')->with('message', 'Document already exists!');
}
else{
Storage::disk("google")->putFileAs("",$request->file("thing"),$name);
$url=Storage::disk('google')->url($name);
$details=Storage::disk("google")->getMetadata($name);
$path=$details['path'];
DB::insert('insert into books (Title, Url, FileId) values (?,?,?)', [$name,$url,$path]);
return redirect()->route('start')->with('message', 'Successfully uploaded document, you have recieved token!');
}
}
})->name("uploads");
请求移动到 http://localhost/Webeng/example/uploads 这是正确的路径,在以前的文件夹中它正在工作但现在说找不到页面
编辑:更正路径错误仍然相同
解决方案
在showForm.blade.php中,您将表单提交到名为upload的路由。但是,在您的路线文件中,您已将路线命名为上传
只需在您的路线文件中更改name("uploads")
为name("upload")
,看看它是否有效
推荐阅读
- node.js - 无法安装 appium - npm ERR!代码 EAI_AGAIN
- arrays - Ruby Array:与数组的 `&` 相对
- android - 如何专业地组织按钮的样式?(SDK 26+,最低 SDK 21)
- delphi - Delphi - FireDAC 事件
- c - C 程序寻找两个人的赞美
- archlinux - 安装 libc++ 时出错
- ios - 深度链接到 ebay 应用 iOS Swift 中的特定产品
- c# - 有人可以解释一下这个示例 C# 代码背后的逻辑吗?多年来我没有得到答案 10
- php - Foreach 插入 Laravel 5 Eloquent
- amazon-web-services - aws s3 同步不将我的文件发送到我的存储桶 AWS S3 (Circleci)