Link to file every downloading

Link to file every downloading

by Helson C -
Number of replies: 3

Hello, i finally got create my local plugin to send a file PDF and put a link in navigation menu... However, when i access the link,

the file is being downloaded. 

localhost/moodle/pluginfile.php/1/local_myplugin/attachment/0/file1.pdf

I tryed pass the param forcedownload=0, but not work.

I'm put the link in a <iframe src="http://localhost/moodle/pluginfile.php/1/local_myplugin/attachment/0/file1.pdf"/>


But when i access, the file is downloaded.


Any help is welcome.

Thanks!



Average of ratings: -
In reply to Helson C

Re: Link to file every downloading

by Darko Miletić -

Almost any file served through pluginfile.php is forced for download regardless of the forcedownload parameter. Only course category, course, course section, backup and few others honor forcedownload param. You should revert to static file. For details look into file_plugin_file function in lib/filelib.php.


In reply to Darko Miletić

Re: Link to file every downloading

by Helson C -

Hey Darko,

looking in detail, i noticed that my argument was not being passed to method:

// sending the file

    send_stored_file($file, 0, 0, true, $options); // download MUST be forced - security! 


Correct:

$forcedownload = 0;

send_stored_file($file, 0, 0, $forcedownload, $options); 


I don't know why but it works.


Gracias!!