im using CakePHP 2.1 and DOMPDF to generate some reports the process is working fine but i can only promt the user to download the file from the controller action using:
$this->response->download('filename');
or open the file in the browser
i am not using any dompdf function to generate the files, the only thing different from accesing a normal view is that i generate the files by adding '.pdf' to the urls like:
mysite.com/controller/action.pdf
I have a folder for my controller view files (one view file for each action in the controller) and inside that folder i have another folder called pdf where i have put the view file for the action that is generating the pdf file, this view file is a normal .ctp file with all the html/php needed to correctly generate the pdf file
The thing i want its to be able to save the generated pdf file to the server so that i can setup a cronjobs to send this files daily at night. The generated file is rendered as a pdf file and can be handled with cakeresponse.
thank you
Well, instead of sending the content just store the file on disk and keep a reference to that file so that you know the file belongs to a certain record.
When requested get the file from disk and send it. I don't get your problem here? Either this is a "write the code for me" style question or are you simply asking for that concept?
Related
I am using TCPDF to generate the PDF, when I open a PDF file on my browser within the application use, with URL viewDocument.php look like these,
And when it is downloaded, view downloadDocument.php
Not understanding why this problem is occurring, really do not understand.Please Help!!
I need to find a way to upload a pdf file to my terms & services page in opencart2. I've looked for an extention, but the suitable extentsion are for opencart 1.5.x.
Is there a way to upload a pdf file and make it downloadable on the information page?
The easiest way would be to upload the file using FTP to a location within your website (e.g. the downloads subdirectory), then put a link to it on the information page using the information page editor. (e.g. http://www.tuinenmetgevoel.nl/downloads/myfile.pdf)
I have a folder called pdf where user will upload pdf's in it,i want a php script which will run for every five minutes to read the pdf folder in order to check for the newly added files in that folder?and intimate to the admin that few files with the following file names are added,how can i do that using php
php scripts cannot auto execute it only execute if there is request made to them..
a simple idea in your case could pe
1.write a php function with the logic to see if filesystem has changed and do the necessary
action(email/database update) on execution.
place & call this function on your home page(index.php).
For image upload we use FILE html controller.
How this html controller able to browse in the local system?
After selecting a file , it will be copied and moved to server location.
If the php is ale to copy the local file and move to server , will it be able to do any other manipulations of that file ? like delete!
What is happening actually on file upload?
The HTML control is provided by the browser. The browser is a local application and has access to the user's file system. The file's contents are sent to the receiving script by the browser using standard methods.
PHP has no access to the user's file system at any point, just the copy provided by the browser. Deleting or even reading files on the user's file system is not possible.
Actually php is not accessing local system. After you choose a file and click upload at upload form. The whole file(not location) is sent via POST request. And php just recieves that POST request with the whole file, and stores at server.
I have a problem regarding to prevent download and saving of uploaded files.
My users can upload multiple files types like doc, pdf, ppt,etc....
This all file types are easily download if any one have url.
So what is the better way to prevent the download of the file.
Or i convert the uploaded files to some specific format which can not download easily (e.g flash)..
I am running on php and mysql.
Thanks
Avinash
You have two options in this regard. The first is to move the files, through a PHP script, to a server-side folder outside of the server's web directory. The second is to store the files in a BLOB column in a MySQL table. Both will prevent users from accessing the files directly, without the need to convert the file to a not-so-easily-downloaded format.
Upload the files outside of your document root. For example:
/var/username/uploads/file.docx
where your document root is
/var/username/public_html/index.php
So they can't be accessed directly. And then if you want to allow downloads, create a PHP file called "download.php" that does something similar to:
$data = file_get_contents('/var/username/uploads/file.docx');
header('Content-Type: application/docx');
header('Content-Length: '.strlen($data));
header('X-Content-Type-Options: nosniff');
echo $data;
and obviously you can add checks to see if the user has the proper permissions to download this particular file or is logged in.
A solution can be to set a user and a password to the upload folder, so only the users that know authentification details can download files.
Check next link for learn how to make htpasswd files on your server folders:
http://httpd.apache.org/docs/1.3/programs/htpasswd.html