current position：Home>How to download files to browser through PHP FTP
How to download files to browser through PHP FTP
2022-02-02 21:44:47 【CSDN Q & A】
I'm developing an online file management feature , I hope users can pass php Download remote FTP The file of
Use HTML Of A Label matching download Use can meet some requirements , However, when a file can be opened directly by the browser, he will open it and download the opened code , Not the source code （ for example ： There is a in my remote service index.php file , I want to download him My initial idea was that the file management system would download remote files to a local directory , The front-end allows users to jump to this directory and directly obtain This method ZIP Etc format is feasible, but encountered php html txt When the browser can be opened directly, it cannot be downloaded directly, or the downloaded file is the file after the code runs ）
Refer to the answer 1：
$a="test.php";// file name $b=fopen($a,"rb");Header("content-type:application/octet-stream");Header("accect-ranges-bytes");Header("accect-length:".filesize($a));Header("content-disposition:attachment;filename=".$a);echo fread($a,filesize($a));fclose ($a);exit();
Refer to the answer 2：
author[CSDN Q & A],Please bring the original link to reprint, thank you.
The sidebar is recommended
- *PTR is a value and a is a pointer. How can they be equal? Shouldn't it be * PTR = & A?
- Specify local time to run code?
- Why is a < B short circuited?
- Usually in face recognition, what operations do we need to do (such as division)? How many times does each operation need to be done? What is the data specification of the operation?
- Firefox browser of win10 system is not connected to the Internet
- Must JNA load DLL be an absolute path? The relative path will report an error every time it is loaded lang.UnsatisfiedLinkError
- Server error in '/ CMS parameters' application.
- The MAC installs windows virtual machine and QT reports an error
- On string array as function parameter
- How to figure out HTML5
guess what you like
What is the specific idea to realize the comment function
The number of occurrences of certain fields in SQL query
Programming with eclipse Java
Get function usage, how to use, high adoption rate
MNIST dataset with KNN algorithm
The so-called palindrome number is the same number from left to right and from right to left. For example, 121 is a palindrome number. Write a program to find the number of palindromes that can be divided by 3 in the range of 100-m. (can anyone see where
Solve the problem of binding this point in anti chattering throttling
Find the factorial of 0-5 by function
JSP get the current URL parameter
Why does this program time out?
- Why did you output more
- Text file problem output new file
- Guess numbers and write programs in C + +
- For the field of int type set, when 0 is entered, the database is null and empty
- Design a mathutils Java class file
- The problem of C language do while loop
- Using random class, randomly generate five integers between 1 and 100, add the generated random integers to a list set, and then calculate the sum of all numbers in the set
- Python pyecharts draws a line chart, and the line breaks randomly
- When the ie11 browser fetches local files, it gets stuck for about 1 minute. How can I solve it?
- How can we understand the data structure and algorithm?
- It is said that the new project given by the company can run before. Now I run and report this error, and I don't know why to add the GIT of the configuration file. Can you help me have a look
- Import data into the database and analyze it
- In vue3 setup, the data change of the object cannot be observed by the watch, and the reason is unknown
- Single chip microcomputer four digit nixie tube rolling display 0-F
- The applet customizes the slider slider and makes the number in decimal form
- How to solve the problem that the time caused by VPN is not the same as the system time?
- Is there anyone to answer
- 2. If there are multiple catches in a program segment, which of the following conditions will the program execute?
- Why delete an element in the set and return 1 Σ (っ ° Д °;) っ？
- GetElementsByTagName ('li ') whether to obtain Li elements of the same level or all Li elements in it
- Why is the time complexity of nested while loops in for still o (n)
- Spring cannot load the context. What's the problem
- What's the problem, please
- C language reading program, why 5? Seek explanation
- How can the Java background distinguish the clients of different users when the company has the same LAN
- Batch import needs to be added in the system
- I can't even paste it a little
- The input value is incorrect. There are two inputs, but only one can be entered
- Why judge whether the triangle is wrong and how to write it.
- How to solve the hidden bug of fluent Web text overflow overflow
- C sharp mouse penetration
- Idea uses el and JSTL expressions respectively, which are written in JSP files and display blank space on the web. What's the problem.
- H3C help me, you fool. I really didn't attend class
- What's the problem with not running at all
- How to open with sqlyog Enterprise Edition MDF and LDF files. SQL Server2008 is not used in class teaching
- C language and application file programming program
- What does the code in Android XML mean? Please have a look
- The branch jump instruction in risc-v requires several branch delay slots
- No change with non singleton labels? What's wrong