本文整理汇总了PHP中Illuminate\Support\Facades\Storage::mimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::mimeType方法的具体用法?PHP Storage::mimeType怎么用?PHP Storage::mimeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Storage
的用法示例。
在下文中一共展示了Storage::mimeType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storeFromUrl
public function storeFromUrl($url, $path, $name)
{
$counter = 1;
if (Storage::exists($path . '/' . $name . '.' . pathinfo($url, PATHINFO_EXTENSION))) {
while (Storage::exists($path . '/' . $name . '-' . $counter . '.' . pathinfo($url, PATHINFO_EXTENSION))) {
$counter++;
}
$name = $name . '-' . $counter;
}
$file = file_get_contents($url);
if (Storage::put($path . '/' . $name . '.' . pathinfo($url, PATHINFO_EXTENSION), $file)) {
$this->filename = $path . '/' . $name . '.' . pathinfo($url, PATHINFO_EXTENSION);
$this->mime = Storage::mimeType($path . '/' . $name . '.' . pathinfo($url, PATHINFO_EXTENSION));
$this->original_filename = $url;
$this->save();
return $this->id;
} else {
return false;
}
}
示例2: fileDetails
/**
* Return an array of file details for a file
*/
protected function fileDetails($path)
{
$path = '/' . ltrim($path, '/');
return ['name' => basename($path), 'fullPath' => $path, 'webPath' => $this->fileWebpath($path), 'mimeType' => Storage::mimeType($path), 'size' => $this->fileSize($path), 'modified' => $this->fileModified($path)];
}
示例3: viewFile
public function viewFile($name)
{
return response()->make(Storage::get($name), 200, ['Content-Type' => Storage::mimeType($name), 'Content-Disposition' => 'inline; ' . $name]);
}
示例4: getImage
public function getImage(Request $request, $image_hash)
{
$file = Storage::get('images/' . $image_hash);
$mimeType = Storage::mimeType('images/' . $image_hash);
$response = \Illuminate\Support\Facades\Response::make($file, 200);
$response->header("Content-Type", $mimeType);
return $response;
}