2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

フルパスとは〜物理パスとURLパスについて〜

Posted at

フルパス(Full Path) とは、特定のファイルやディレクトリの 「完全な場所」を示すパス のことです。
状況によって意味が若干異なる場合がありますが、通常は以下のいずれかを指します。


1. サーバー上のフルパス

これは、物理パスとほぼ同じ意味で使われることが多いです。

定義

  • サーバーのルートディレクトリ(/)から始まる、ファイルやディレクトリへの完全なパスです
  • サーバーのファイルシステム上で操作する際に使用されます
  • Linux のファイルパスに限っていうと、頭に「/」がつくのが絶対PATHになります

  • Linuxサーバーの場合:
/var/www/html/my_project/storage/app/product_images/12345/image.jpg
  • Windowsサーバーの場合:
C:\xampp\htdocs\my_project\storage\app\product_images\12345\image.jpg

Laravelでの使用例
Laravelでは storage_path() を使ってこのフルパスを取得できます。

$fullPath = storage_path('app/product_images/12345/image.jpg');
echo $fullPath;
// 出力例: /var/www/html/my_project/storage/app/product_images/12345/image.jpg

2. URLとしてのフルパス

Webアプリケーションでは、公開されているファイルやディレクトリへの完全なURLパスをフルパスと呼ぶことがあります。

定義

  • サイトのドメインを含む、ブラウザでアクセス可能な完全なURL
  • 通常、公開されているファイルに対して使用されます
  • Webサーバーが public/storage を公開している場合
https://example.com/storage/product_images/12345/image.jpg

Laravelでの使用例
LaravelではStorage::url() を使って公開URLとしてのフルパスを生成できます。

$fullUrl = Storage::url('product_images/12345/image.jpg');
echo $fullUrl;
// 出力例: https://example.com/storage/product_images/12345/image.jpg

「フルパス」と「物理パス」の違い

物理パス:

  • サーバー上のファイルシステムでのパス(完全に内部向け)
  • 公開されていないファイルも含む

フルパス:

  • 一般的には「完全な場所」を指すが、文脈によって物理パスまたは公開URLのどちらかを意味する

まとめ

  • 物理パスのフルパス: サーバーのファイルシステム内での絶対パス。例: /var/www/html/...
  • URLのフルパス: ブラウザからアクセスできる完全なURL。例: https://example.com/...
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?