我想获取我上传的绝对路径,可是只获取了文件名,和模版文件!求帮助怎么获取我上传的绝对路径。
回复讨论(解决方案)
那个绝对路径是上传者的机器上的,跟你有什么关系?
你只要处理你收到的文件就可以了
不知道你要获取那个路径干什么,真想获取,用js试试看。
那个绝对路径是上传者的机器上的,跟你有什么关系?
你只要处理你收到的文件就可以了
不知道你要获取那个路径干什么,真想获取,用js试试看。
PHP有没有对应的方法可以获取,应该刚转PHP没有多久。网上没有找到对应资料。你在北京,我在上海,如果我上传了一个 excel 文件,那么你要到我的机器上将他转成 csv 文件吗?
文件被上传后,默认地会被储存到服务端的默认临时目录中,除非 php.ini 中的 upload_tmp_dir 设置为其它的路径。服务端的默认临时目录可以通过更改 PHP 运行环境的环境变量 TMPDIR 来重新设置
如果实在没办法找出那个目录,你可以用move_uploaded_file转存后再做处理,其实也没必要知道那个目录,直接转存后再处理好了。
必须要用js来获取input框的值放入隐藏域中,然后一起提交。
别弄复杂了,你可以提示用户必须上传csv文件。
你在北京,我在上海,如果我上传了一个 excel 文件,那么你要到我的机器上将他转成 csv 文件吗?
按你这样说肯定是在他那边转换完成。但是我现在需要不是文件,而是文件里面数据,直接本地导入后把数据存到数据库当中。
必须要用js来获取input框的值放入隐藏域中,然后一起提交。
别弄复杂了,你可以提示用户必须上传csv文件。
即使你获取了那个文件的本地路径,你能用js修改他本地文件?
文件被上传后,默认地会被储存到服务端的默认临时目录中,除非 php.ini 中的 upload_tmp_dir 设置为其它的路径。服务端的默认临时目录可以通过更改 PHP 运行环境的环境变量 TMPDIR 来重新设置
如果实在没办法找出那个目录,你可以用move_uploaded_file转存后再做处理,其实也没必要知道那个目录,直接转存后再处理好了。
即使你获取了那个文件的本地路径,你能用js修改他本地文件?
用 PHP代码 可以重新生成一个CSV文件出来。这我试过,可以。那你就判断一下上传的文件(那个临时文件)的类型就可以了吧,如果判断类型为execl类型的话,用php转一下呗
请问你要干什么???上传文件会生成临时文件名 操作这个就行了 PHP有检查类型的函数 你本末倒置了吧
浏览器不给网页获取本地数据的权限,你只能把excel文件直接传到服务器临时目录,然后在服务器处理文件,处理完后再导入数据库。
这是唯一的方法。
文件被上传后,默认地会被储存到服务端的默认临时目录中,除非 php.ini 中的 upload_tmp_dir 设置为其它的路径。服务端的默认临时目录可以通过更改 PHP 运行环境的环境变量 TMPDIR 来重新设置
如果实在没办法找出那个目录,你可以用move_uploaded_file转存后再做处理,其实也没必要知道那个目录,直接转存后再处理好了。
你不是上传文件吗?这个函数怎么不能使用?这个函数是上传专用的,其它地方还用不起来。可以移到你能移的目标位置,然后随意你处理了。
即使你获取了那个文件的本地路径,你能用js修改他本地文件?
你能用js修改用户电脑上的文件???奇迹啊。。。
你想要让用户录入多条数据,然后保存到数据库中。
如果你能够处理Excel,得到用户上传的Excel文件后,通过后台程序直接从Excel文件提取出数据,然后保存。
如果你不能处理Excel,那么就不要让用户上传Excel文件,换成其他你能够处理的数据格式,比如直接进行表单录入或者按照固定格式上传txt文件。
至于获取用户上传的文件在用户电脑中的绝对路径,就不要想了,即使获取到了,你也无法对用户电脑上的文件进行操作。
即使你获取了那个文件的本地路径,你能用js修改他本地文件?
你能用js修改用户电脑上的文件???奇迹啊。。。
你想要让用户录入多条数据,然后保存到数据库中。
如果你能够处理Excel,得到用户上传的Excel文件后,通过后台程序直接从Excel文件提取出数据,然后保存。
如果你不能处理Excel,那么就不要让用户上传Excel文件,换成其他你能够处理的数据格式,比如直接进行表单录入或者按照固定格式上传txt文件。
至于获取用户上传的文件在用户电脑中的绝对路径,就不要想了,即使获取到了,你也无法对用户电脑上的文件进行操作。
楼上正解

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

Using preprocessing statements and PDO in PHP can effectively prevent SQL injection attacks. 1) Use PDO to connect to the database and set the error mode. 2) Create preprocessing statements through the prepare method and pass data using placeholders and execute methods. 3) Process query results and ensure the security and performance of the code.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP makes it easy to create interactive web content. 1) Dynamically generate content by embedding HTML and display it in real time based on user input or database data. 2) Process form submission and generate dynamic output to ensure that htmlspecialchars is used to prevent XSS. 3) Use MySQL to create a user registration system, and use password_hash and preprocessing statements to enhance security. Mastering these techniques will improve the efficiency of web development.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version
SublimeText3 Linux latest version

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software