简体   繁体   中英

Forcing html code to download as a file (PHP, jQuery)

First of all, I did a lot of research already and none of the solutions apply to me. My problem seems to be a little more specific.

I have one html page on which I am generating a html content (to be more specific, it's a gallery that loads images from user's Dropbox account).

It would be a huge privacy issue to store the gallery on the server so I need to save the html code into a file on user's computer directly.

I tried two major solutions:

1) one php file - I don't think it's possible to do this, because the page will reload and the html code is then lost

2) separate html (login to Dropbox, generate gallery) and php (saving) files - it seems to be impossible to send the gallery code to the php file through ajax.

Any ideas, please?

This is a pretty open-ended question, my main goal is to come up with a privacy conscious solution so that the user can save it and doesn't have to wonder if I'm keeping his or her data.

One idea, for example: save the gallery as a file (I know how to do this part) and after the file is downloaded, delete it?

I would save it to the server, and then use PHP to download the file. If you need to delete it after, do that.

$fp = fopen ("http://www.example.com/yourfile.html", "r");

while (!feof ($fp)) 
{
    $buffer = fgets($fp, 4096);
    echo $buffer;
}

fclose ($fp);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM