我允许用户在我的页面上传任何类型的文件,但文件名可能存在冲突.因此,我想自动重命名文件,以便任何时候上传任何文件,在数据库和上传后的文件夹中,当其他用户下载相同的文件时,文件名也会被更改,重命名的文件将被下载.我试过了:
if (Input::hasFile('file')){
echo "Uploaded</br>";
$file = Input::file('file');
$file ->move('uploads');
$fileName = Input::get('rename_to');
}
Run Code Online (Sandbox Code Playgroud)
但是,名称改为:
php5DEB.php
phpCFEC.php
我该怎么做才能以相同的类型和格式维护文件,只需更改其名称?
我也想知道如何在页面上显示最近上传的文件并让其他用户下载?
我正在尝试打开 C:\\xampp\\htdocs 文件夹的索引,但是当我尝试时:
\n\n\n本地主机:8000\n\n本地主机:8000/index
\n
表明:
\n\n\n无法访问此站点\xe2\x80\x99
\n本地主机拒绝连接。\n在 Google 中搜索本地主机 8000 索引
\n
如何在浏览器上打开 htdocs 文件夹的索引?
\n即使我尝试过:
\n\n\n本地主机:8000/wordpress
\n
它显示了同样的错误:
\n\n\n无法访问此站点\xe2\x80\x99
\n本地主机拒绝连接。
\n
我不明白有什么问题?
\n当我尝试上传文件时显示错误:
未定义的变量:请求
这是我使用它的地方:UploadController:
if($request->hasFile('file')){
$file = $request ->file('file');
$fileName = $file->getClientOriginalName();
$destinationPath = config('app.fileDesinationPath').'/'.$fileName;
$uploads = Storage::put($destinationPath,file_get_contents($file->getRealPath()));
}
return redirect()->to('/upload');
Run Code Online (Sandbox Code Playgroud)
这有什么不对?
我第一次看到这个错误,真的不知道该怎么办。当我尝试在我的网站上注册新用户并单击提交按钮时,它显示:
FatalErrorException in User.php line 11: Class App\User 包含 6 个抽象方法,因此必须声明为抽象方法或实现其余方法 (Illuminate\Contracts\Auth\Authenticatable::getAuthIdentifierName, Illuminate\Contracts\Auth\Authenticatable::getAuthIdentifier, Illuminate\Contracts\Auth\Authenticatable::getAuthPassword, ...)
用户模型:
<?php
namespace App;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
class User extends Model implements Authenticatable
{
protected $table = 'users';
protected $primaryKey = 'id';
}
Run Code Online (Sandbox Code Playgroud)
它想说什么,我不明白。请有人帮我解决这个问题吗?