This topic is locked
[SOLVED]

 Mark File as Downloaded

2/12/2014 5:12:16 AM
PHPRunner General questions
P
prattster1874 author

Hi,
Can anyone give me a clue as to how I would mark a file as downloaded?
I have a table with file attachments and I would like to mark the ones that have been downloaded as "Read". I have a "Read" flag in the table, but am not sure how to set the flag?
Thanks!!

Sergey Kornilov admin 2/13/2014

Unfortunately we do not have such functionality in PHPRunner. We'll consider adding it.

P
prattster1874 author 2/13/2014



Unfortunately we do not have such functionality in PHPRunner. We'll consider adding it.


I think that it would be a good addition. I have worked out a way to do it, but for some reason it doesn't work intermittently:
Javascript on load:

$('a').mouseup(function(){



var key=this.getAttribute("href");

var res = key.split("=");
if(res[0]=="mfhandler.php?file"){

//alert(res[0]);
$.ajax({

type: "POST",

url: "include\\ci\\read_doc.php",

data: { ID:res[5],user:usern},

success: $.runnerAJAX(Runner.pages.getUrl(pageObj.tName, pageObj.pageType)+"?a=return",
pageObj.ajaxBaseParams,
function(respObj){
pageObj.pageReloadHn.call(pageObj, respObj)

})


});


}
});


The script reads the href attribute of the link to get the file info, read_doc.php just sets the flag, and adds user and datestamp. I have declared the usern variable using a code snippet on the main page to get the username.
The problem is that sometimes the AJAX requests get cancelled by the browser - I think - because it is following the link but I'm not sure how to fix that, I would be grateful for any ideas. I am not a javascript expert - yet!! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=74026&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />
It does work OK for the most part though!!

Sergey Kornilov admin 2/14/2014

I'm afraid I don't have any comment here on why it may or may not work every time.
This sort of thing needs to be handled on the server side meaning you need to modify generated PHP file that provides file download functionality. In recent versions of PHPRunner this file is mfhandler.php.