Laravel 5 调用未定义的函数 App\Http\Controllers\riderect() 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42745677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5 Call to undefined function App\Http\Controllers\riderect() Error
提问by Dasun
I'm new to the laravel and I'm developing a file uploading system. The files are uploaded and stored to the database just fine, but when I try to call the delete method, it gives this error:
我是 laravel 的新手,我正在开发一个文件上传系统。文件上传并存储到数据库就好了,但是当我尝试调用删除方法时,它给出了这个错误:
Call to undefined function App\Http\Controllers\riderect()
调用未定义的函数 App\Http\Controllers\riderect()
Here is the FileUpload Controller and its delete method:
这是 FileUpload Controller 及其删除方法:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Redirect;
use App\UploadedFile;
class FilesController extends Controller
{
public function deleteFile($id)
{
$file = UploadedFile::find($id);
Storage::delete(config('app.fileDestinationPath').'/'.$file->filename);
return riderect()->to('uploaded');
}
}
How can this error be avoided?
如何避免这个错误?
回答by James
It is a spelling error, this:
这是一个拼写错误,这个:
return riderect()->to('uploaded');
Should be:
应该:
return redirect()->to('uploaded');
回答by Paras
Replace riderect()->to('uploaded');
with redirect()->to('uploaded');
替换riderect()->to('uploaded');
为redirect()->to('uploaded');