Tracking Attachement Downloads/Views - php

Is there any way to track how many times an attachment has been viewed and/or downloaded? I am adding attachments using a custom metabox and just want a way to track the file downloads/views. Any direction would be greatly appreciated.

Instead of attaching the file to mail provide the file name in mail like linked to your download php file when someone clicks on your file name it will redirect to your download php file and there you can provide the force download of that file and there in php file you can track the users by storing there ips into database or provide some unique id to file link in every mail and store it to database with count= 0 when every time user clicks on file name then update the count.
i have developed a portal similar to wetransfer and i have used this apporach there to achieve the same thing.

Related

Upload files automatically to an input file from a path

I got a DDBB with some paths from different files that I keep in a table. What I'm trying to do is the following:
You can click a button which gets all that paths and loads all the files to an input file just to send it as attached file via e-mail using a php script.
The thing is, I don't know if it is really necessary to take that step with jquery or is it possible to send it straight away using php?
If I understand correctly, you have file paths in DB, which is Backend, and when you create page view you are getting paths from DB by PHP still Backend, then you will put a hidden field etc. when a person click a button 'Frontend but dummy action' you want to load these files and send to backend again.
Logically;
If Client and Server are not discrete then this wouldn't be a reliable system, because you are not sure files are in the correct path which means will not be renamed, deleted.
If client and server are the same you don't need to make this with a file upload you already know you have the paths when user click the button ex : button submits the form with id/group_id 1, fetch paths by id or group_id and send by email.
But still you want to do something like that, Html5 has an api http://www.w3schools.com/jsref/dom_obj_fileupload.asp for it, beyond that you need to execute an applet to achieve this I think.

Codeigniter - Download a upload file in the directory

I'm using the latest Codeigniter version, and I write a program about basic file uploading and download helper in http://ellislab.com/codeigniter%20/user-guide/helpers/download_helper.html.
I want to create a system that will upload a multiple files to the directory and save the file name to the database and the name of the uploader, and will have function to have download links to download every file of that specific user. If possible the system can email the encrypted link to the users to download the file. And can only download for specific time..
I don't know the logic in dynamic files to download. Can someone teach how to do this or what logic can solve this problem. Thank you very much! :)
For multiple files you have some alternatives, you can create each field as a user press a button or use the multiple propriety to <input> tag.
To manage this multiple uploads you must create your own upload library reading each $_FILES['nameoffield'] in a foreach loop for example although there are alternatives ready to be used like: https://github.com/nicdev/CodeIgniter-Multiple-File-Upload
On your database, you could have two fields that stores the original file name and path, and the encrypted one. Probably associated to a random unique number or timestamp.
To email encrypted link, and by encrypted I think you are saying a disguised link to the file, not using original name, you simple select the field which store the encrypted name to a controller, like download and keep a variable to receive a value as parameter. This value you must check on database if it really exists and then redirect to the file. By doing that you should have your file being downloaded.

How to write to database in Symfony2, when a link is clicked on the website?

In a project I'm working on, the client has required that every time a user clicks on a link to download (they will be downloading a video or mp3), there should be a log kept of who has downloaded what and when.
I have a table in my database set up to record the User ID, the File ID, and the date when it was downloaded. However, I don't know how to do this, as the link is basically an tag (obviously).
What is the best way to achieve this?
Probably the simplest solution would be to write simple onclick ajax event.
If you want noscript solution you'll have to create some download wrapper, that'd serve you proper file. Just create special route and controller (eg. /downloads/filename), increment download meter for this one and return asset instead of html response. Don't forget to set proper Content-Type header tho.
There's also IgorwFileServeBundle that could help you loads.
Instead of linking to the MP3 file, you'll have to funnel the download through a PHP script that writes to the database and then sends the MP3 data with with the right headers. For maximum performance use the "X-Sendfile" header instead of the PHP readfile function.
Alternatively you could set up a cron job for a Symfony console command line tool that parses the Apache access log and writes to the DB whenever it encounters an MP3 file.

how to make an interactive uploader like gmail and facebook have?

I want to make a interactive uploading option like Facebook and gmail have where they show the progress of the current file in uploading and then show the respective image or name of the file over there after the upload.
Right now, i'm using php and normal html for uploading where i send the file from one page to another where php handles it accordingly but i want a interactive one which show the progress also on the same page and then the name of the file after uploading without page refresh.
I knew, it can be done with ajax and css but i don't know how. All i want a interactive upload-er which uploads the file and then provide me the respective file name.
Gmail uses firefox file api, read more about it here https://developer.mozilla.org/en/Using_files_from_web_applications
Or check this live demo
http://robertnyman.com/html5/fileapi-upload/fileapi-upload.html
Hope this will help/solve ur problem ;) best luck

How to attach multiple pdfs from directory (in server) to email attachments in PHP

I made a form that can send form details to database then convert results to pdf (*pdfcrowd).
I have saved the filename(*of the pdf) inside the database and the pdf is saved inside a folder directory too.
Everything is working fine. EXCEPT that i'm stuck on how to get the pdf files.
The user is going to see the tables. I'll provide a checkbox and when the checkbox is clicked, the filename in the row should be included on what to attach in the email.
My database is Recipes, Table: Recipe_list, The field where filename is saved is.. "recipe_name" and the folder where the pdfs files are inside "/recipes/" folder.
I don't understand the "MIME" and other stuff about email attachment. I would appreciate if you can help me with this.
you can refer below link for this task,
http://www.emanueleferonato.com/2008/07/22/sending-email-with-multiple-attachments-with-php/
this would be very much helpful to you.
Thanks.

Categories