Home > Backend Development > PHP Tutorial > 文件上传的时候指定路径中的./和/和../的区别

文件上传的时候指定路径中的./和/和../的区别

WBOY
Release: 2016-06-06 20:29:33
Original
1155 people have browsed it

文件上传的路径是相对于服务器的根目录还是相对于文件上传scirpt而言的。
另外上传路径有时候

<code>uploads/
/uploads/
./uploads/
../uploads/
</code>
Copy after login
Copy after login

这几个究竟有什么区别呀。彻底要被路径搞混了。

回复内容:

文件上传的路径是相对于服务器的根目录还是相对于文件上传scirpt而言的。
另外上传路径有时候

<code>uploads/
/uploads/
./uploads/
../uploads/
</code>
Copy after login
Copy after login

这几个究竟有什么区别呀。彻底要被路径搞混了。

假设script所在路径:/data/www/project/script

目录结构:

<code>/
data/
  www/
    uploads/ ①
    project/
      uploads/ ②
      script
uploads/ ③</code>
Copy after login

那么:
uploads/ 是②
/uploads/ 是③
./uploads/ 是②
../uploads/ 是①

<code>uploads/ ==》当前路径平级的uploads目录
/uploads/==》当前路径根目录下的uploads目录
./uploads/==》当前路径前1级目录下的uploads目录
../uploads/==》当前路径前2级目录下的uploads目录</code>
Copy after login

楼上正确,我习惯是尽量用/打头写相对根路径

我觉得你打印输出一下就会得到答案。。。

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template