Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial 我想获取我上传的绝对路径,可是只获取了文件名,和模版文件!求帮助怎么获取我上传的绝对路径。

我想获取我上传的绝对路径,可是只获取了文件名,和模版文件!求帮助怎么获取我上传的绝对路径。

Jun 23, 2016 pm 01:57 PM
upload stencil absolute path Obtain



回复讨论(解决方案)

那个绝对路径是上传者的机器上的,跟你有什么关系?
你只要处理你收到的文件就可以了

不知道你要获取那个路径干什么,真想获取,用js试试看。

那个绝对路径是上传者的机器上的,跟你有什么关系?
你只要处理你收到的文件就可以了

我想获取绝对路径,然后进行格式转换,有时候别人可能上传的是EXECL文件。可是Execl处理不了,我必须转换成CSV格式的,才能处理。

不知道你要获取那个路径干什么,真想获取,用js试试看。

PHP有没有对应的方法可以获取,应该刚转PHP没有多久。网上没有找到对应资料。

你在北京,我在上海,如果我上传了一个 excel 文件,那么你要到我的机器上将他转成 csv 文件吗?

文件被上传后,默认地会被储存到服务端的默认临时目录中,除非 php.ini 中的 upload_tmp_dir 设置为其它的路径。服务端的默认临时目录可以通过更改 PHP 运行环境的环境变量 TMPDIR 来重新设置
如果实在没办法找出那个目录,你可以用move_uploaded_file转存后再做处理,其实也没必要知道那个目录,直接转存后再处理好了。

必须要用js来获取input框的值放入隐藏域中,然后一起提交。

别弄复杂了,你可以提示用户必须上传csv文件。

你在北京,我在上海,如果我上传了一个 excel 文件,那么你要到我的机器上将他转成 csv 文件吗?

按你这样说肯定是在他那边转换完成。但是我现在需要不是文件,而是文件里面数据,直接本地导入后把数据存到数据库当中。

必须要用js来获取input框的值放入隐藏域中,然后一起提交。

别弄复杂了,你可以提示用户必须上传csv文件。

我先前是那么做的,是经理硬要改成让别人也可以直接上传Execl。我想想用JS怎么实现把。

即使你获取了那个文件的本地路径,你能用js修改他本地文件?

文件被上传后,默认地会被储存到服务端的默认临时目录中,除非 php.ini 中的 upload_tmp_dir 设置为其它的路径。服务端的默认临时目录可以通过更改 PHP 运行环境的环境变量 TMPDIR 来重新设置
如果实在没办法找出那个目录,你可以用move_uploaded_file转存后再做处理,其实也没必要知道那个目录,直接转存后再处理好了。

这个方法(move_uploaded_file)在这里不能使用,他好像是服务器生成出来的缓存文件,如果是上传Execl的话,也会提前会转了,如果转了的话。就会数据不对。所以我想在上传完成后,点确定时候,我先把Execl文件转换成Csv格式,然后在直接使用就好了,程序也不需要变动。我先尝试用JS试试。刚学还有许多东西需要了解的,不过你刚说的原理。对我还是挺有用的,谢谢了。

即使你获取了那个文件的本地路径,你能用js修改他本地文件?

用 PHP代码 可以重新生成一个CSV文件出来。这我试过,可以。

那你就判断一下上传的文件(那个临时文件)的类型就可以了吧,如果判断类型为execl类型的话,用php转一下呗

请问你要干什么???上传文件会生成临时文件名 操作这个就行了 PHP有检查类型的函数 你本末倒置了吧

浏览器不给网页获取本地数据的权限,你只能把excel文件直接传到服务器临时目录,然后在服务器处理文件,处理完后再导入数据库。
这是唯一的方法。


文件被上传后,默认地会被储存到服务端的默认临时目录中,除非 php.ini 中的 upload_tmp_dir 设置为其它的路径。服务端的默认临时目录可以通过更改 PHP 运行环境的环境变量 TMPDIR 来重新设置
如果实在没办法找出那个目录,你可以用move_uploaded_file转存后再做处理,其实也没必要知道那个目录,直接转存后再处理好了。

这个方法(move_uploaded_file)在这里不能使用,他好像是服务器生成出来的缓存文件,如果是上传Execl的话,也会提前会转了,如果转了的话。就会数据不对。所以我想在上传完成后,点确定时候,我先把Execl文件转换成Csv格式,然后在直接使用就好了,程序也不需要变动。我先尝试用JS试试。刚学还有许多东西需要了解的,不过你刚说的原理。对我还是挺有用的,谢谢了。
你不是上传文件吗?这个函数怎么不能使用?这个函数是上传专用的,其它地方还用不起来。可以移到你能移的目标位置,然后随意你处理了。


即使你获取了那个文件的本地路径,你能用js修改他本地文件?

用 PHP代码 可以重新生成一个CSV文件出来。这我试过,可以。
你能用js修改用户电脑上的文件???奇迹啊。。。

你想要让用户录入多条数据,然后保存到数据库中。
如果你能够处理Excel,得到用户上传的Excel文件后,通过后台程序直接从Excel文件提取出数据,然后保存。
如果你不能处理Excel,那么就不要让用户上传Excel文件,换成其他你能够处理的数据格式,比如直接进行表单录入或者按照固定格式上传txt文件。

至于获取用户上传的文件在用户电脑中的绝对路径,就不要想了,即使获取到了,你也无法对用户电脑上的文件进行操作。



即使你获取了那个文件的本地路径,你能用js修改他本地文件?

用 PHP代码 可以重新生成一个CSV文件出来。这我试过,可以。
你能用js修改用户电脑上的文件???奇迹啊。。。

你想要让用户录入多条数据,然后保存到数据库中。
如果你能够处理Excel,得到用户上传的Excel文件后,通过后台程序直接从Excel文件提取出数据,然后保存。
如果你不能处理Excel,那么就不要让用户上传Excel文件,换成其他你能够处理的数据格式,比如直接进行表单录入或者按照固定格式上传txt文件。

至于获取用户上传的文件在用户电脑中的绝对路径,就不要想了,即使获取到了,你也无法对用户电脑上的文件进行操作。
楼上正解
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to get file extension in Python? How to get file extension in Python? Sep 08, 2023 pm 01:53 PM

A file extension in Python is a suffix appended to the end of a file name to indicate the format or type of the file. It usually consists of three or four characters, a file name followed by a period, such as ".txt" or ".py". Operating systems and programs use file extensions to determine what type of file it is and how it should be processed. Recognized as a plain text file. File extensions in Python are crucial when reading or writing files because it establishes the file format and the best way to read and write data. For example, the ".csv" file extension is the extension used when reading CSV files, and the csv module is used to process the files. Algorithm for obtaining file extension in Python. Manipulate file name string in Python.

How to implement file upload and processing in FastAPI How to implement file upload and processing in FastAPI Jul 28, 2023 pm 03:01 PM

How to implement file upload and processing in FastAPI FastAPI is a modern, high-performance web framework that is easy to use and powerful. It provides native support for file upload and processing. In this article, we will learn how to implement file upload and processing functions in the FastAPI framework, and provide code examples to illustrate specific implementation steps. First, we need to import the required libraries and modules: fromfastapiimportFastAPI,UploadF

Use math.Max ​​function to get the maximum value in a set of numbers Use math.Max ​​function to get the maximum value in a set of numbers Jul 24, 2023 pm 01:24 PM

Use the math.Max ​​function to obtain the maximum value in a set of numbers. In mathematics and programming, it is often necessary to find the maximum value in a set of numbers. In Go language, we can use the Max function in the math package to achieve this function. This article will introduce how to use the math.Max ​​function to obtain the maximum value in a set of numbers, and provide corresponding code examples. First, we need to import the math package. In the Go language, you can use the import keyword to import a package, as shown below: import"mat

Where to get Google security code Where to get Google security code Mar 30, 2024 am 11:11 AM

Google Authenticator is a tool used to protect the security of user accounts, and its key is important information used to generate dynamic verification codes. If you forget the key of Google Authenticator and can only verify it through the security code, then the editor of this website will bring you a detailed introduction on where to get the Google security code. I hope it can help you. If you want to know more Users please continue reading below! First open the phone settings and enter the settings page. Scroll down the page and find Google. Go to the Google page and click on Google Account. Enter the account page and click View under the verification code. Enter your password or use your fingerprint to verify your identity. Obtain a Google security code and use the security code to verify your Google identity.

Simple steps to upload your own music on Kugou Simple steps to upload your own music on Kugou Mar 25, 2024 pm 10:56 PM

1. Open Kugou Music and click on your profile picture. 2. Click the settings icon in the upper right corner. 3. Click [Upload Music Works]. 4. Click [Upload Works]. 5. Select the song and click [Next]. 6. Finally, click [Upload].

How to upload lyrics to QQ Music How to upload lyrics to QQ Music Feb 23, 2024 pm 11:45 PM

With the advent of the digital age, music platforms have become one of the main ways for people to obtain music. However, sometimes when we listen to songs, we find that there are no lyrics, which is very disturbing. Many people hope that lyrics can be displayed when listening to songs to better understand the content and emotions of the songs. QQ Music, as one of the largest music platforms in China, also provides users with the function of uploading lyrics, so that users can better enjoy music and feel the connotation of the songs. The following will introduce how to upload lyrics on QQ Music. first

How to get the last element of LinkedHashSet in Java? How to get the last element of LinkedHashSet in Java? Aug 27, 2023 pm 08:45 PM

Retrieving the last element from a LinkedHashSet in Java means retrieving the last element in its collection. Although Java has no built-in method to help retrieve the last item in LinkedHashSets, there are several effective techniques that provide flexibility and convenience to efficiently retrieve this last element without breaking the insertion order - a must for Java developers issues effectively addressed in its application. By effectively applying these strategies in their software projects, they can achieve the best solution for this requirement LinkedHashSetLinkedHashSet is an efficient data structure in Java that combines HashSet and

How to improve computer upload speed How to improve computer upload speed Jan 15, 2024 pm 06:51 PM

Upload speed becomes very slow? I believe this is a problem that many friends will encounter when uploading things on their computers. If the network is unstable when using a computer to transfer files, the upload speed will be very slow. So how can I increase the network upload speed? Below, the editor will tell you how to solve the problem of slow computer upload speed. When it comes to network speed, we all know that the speed of opening web pages, download speed, and upload speed are also very critical. Especially some users often need to upload files to the network disk, so a fast upload speed will undoubtedly save you a lot of money. Less time, what should I do if the upload speed is slow? Below, the editor brings you pictures and texts on how to deal with slow computer upload speeds. How to solve the problem of slow computer upload speed? Click "Start--Run" or "Window key"

See all articles