在laravel项目中,文件上传按钮在使用WAMP服务器的本地开发过程中运行良好。但当我将项目上传到共享托管服务器时,文件上传按钮不再工作。该按钮已禁用。
在我的本地主机中,上传按钮可以工作,但在我的实时服务器中,文件上传按钮不工作(禁用(
请帮帮我,我不知道该怎么办。
在我的控制器中,这是上传的代码
public function upload(Request $request){
$type = array(
"jpg"=>"image",
"jpeg"=>"image",
"png"=>"image",
"svg"=>"image",
"webp"=>"image",
"gif"=>"image",
"mp4"=>"video",
"mpg"=>"video",
"mpeg"=>"video",
"webm"=>"video",
"ogg"=>"video",
"avi"=>"video",
"mov"=>"video",
"flv"=>"video",
"swf"=>"video",
"mkv"=>"video",
"wmv"=>"video",
"wma"=>"audio",
"aac"=>"audio",
"wav"=>"audio",
"mp3"=>"audio",
"zip"=>"archive",
"rar"=>"archive",
"7z"=>"archive",
"doc"=>"document",
"txt"=>"document",
"docx"=>"document",
"pdf"=>"document",
"csv"=>"document",
"xml"=>"document",
"ods"=>"document",
"xlr"=>"document",
"xls"=>"document",
"xlsx"=>"document"
);
if($request->hasFile('aiz_file')){
$upload = new Upload;
$upload->file_original_name = null;
$arr = explode('.', $request->file('aiz_file')->getClientOriginalName());
for($i=0; $i < count($arr)-1; $i++){
if($i == 0){
$upload->file_original_name .= $arr[$i];
}
else{
$upload->file_original_name .= ".".$arr[$i];
}
}
$upload->file_name = $request->file('aiz_file')->store('uploads/all');
$upload->user_id = Auth::user()->id;
$upload->extension = $request->file('aiz_file')->getClientOriginalExtension();
if(isset($type[$upload->extension])){
$upload->type = $type[$upload->extension];
}
else{
$upload->type = "others";
}
$upload->file_size = $request->file('aiz_file')->getSize();
$upload->save();
return '{}';
}
}
在我看来,这是处理上传的代码
<div class="form-group">
<label for="types">{{translate('System Logo - White')}}</label>
<div class="input-group" data-toggle="aizuploader" data-type="image">
<div class="input-group-prepend">
<div class="input-group-text bg-soft-secondary">{{ translate('Browse') }}</div>
</div>
<div class="form-control file-amount">{{ translate('Choose Files') }}</div>
<input type="hidden" name="system_logo_white" value="{{ get_setting('system_logo_white') }}" class="selected-files">
</div>
在laravel.env文件中,url设置不正确。所以我必须纠正它,它起了作用。
旧url-http://example.com
新url-https://example.com/(工作url(