Question about php text generation _ PHP Tutorial

Source: Internet
Author: User
About php text generation. How can I solve the problem about php text generation? I uploaded some data, for example, my personal data, etc. then I want to add a question on the front-end.
Questions about php text generation
Solution
Hello, everyone. The younger brother has a problem.

Now I have uploaded some data, such as my personal data, and I want to add a "download" button on the front-end, after clicking this button, the uploaded data will be automatically generated from the server, and downloaded to your local storage!

Who knows, is there any good way? I have no clue. I just learned the program!

Thank you!


Reference answer
... What data are you uploading .. Bmp? Php?
Reference answer
Is text! For example, is there a solution to text like news, including the question date and content?
Reference answer
Poor understanding .. Don't you understand what you're talking about
Reference answer
This should be simple. fopen --- fwrite --- fclose. you can refer to the code written in text files in the basic textbooks.
Reference answer
I seem to know what you are doing.



// Note: Directory of the file

$ FileDir = './mydata ';



// Note: Check whether the directory is readable.

If (! Is_readable ($ fileDir )){

Die ('permission insufficiency ');

}



// Note: initial file array

$ FileData = array ();



// Note: Read an object

$ Handler = fopen ($ fileDir );

While ($ filename = readdir ($ handler ))! = FALSE ){

If (! In_array ($ filename, array ('.', '..'), TRUE )){

$ FileData [] = file_get_contents ($ filename );

}

}



// Note: You can use the $ fileData array for the operation you need.


I don't know if you want it.
Reference answer
I have never practiced your code, but it seems that the solution is not very good.
Download an object without listing all the files in the directory and placing them in the array.

What do you need to download?
How does the front-end display download?
$ Filename = 'xiaoasp.txt 'if the path and file name are directly displayed; // Here I test it locally. you can use the variable to GET the file name using GET.

Header ("Content-type: application/force-download"); // force download because the txt file is parsed by the browser by default

Readfile ($ filename); // then the output file

Exit;



Reference answer
In fact, my idea is very simple. I just want:

On the background page, the news is uploaded to the server in the form of "title, date, author, and content.
The fields on the server are id title date author content

In this way, I can view my uploaded news on the frontend, which can be easily implemented using php.

However, I suddenly thought that I would add a "download" button in my background, which would achieve the following effect: After clicking it, it will automatically take me a month (default) all the news uploaded to the server in the form of text or word is saved to the local, so that I can watch the news I uploaded in the past without going online. do you understand?

Of course, this is just an example. don't ask me why I don't save it and then upload the news! Haha
Reference answer
Word format? That's not that simple ~ Search for a PHP class that generates Word format files online.
Reference answer
You can download all the text!

Tips: How to solve the php text generation problem Hello everyone. I have a problem with my younger brother. now I have uploaded some data, such as my personal data. then I want to add a "lower..." to the front-end...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.