Page 1 of 1

Assets, media file and direct download -Solved

Posted: Tue Apr 14, 2020 6:39 am
by Julien
Hello community,

I am doing a project with a .pdf available to download.

I have added my abc.pdf to the project assets and made a button with the action: mouse click -> go to URL -> assets/abc.pdf
Generating the project and calling the button, it takes us to the pdf webpage with the Print, Download, etc options.

Instead of landing to this pdf webpage, is it possible to get the asset file to be directly downloading only?

Julien

Re: Assets, media file and direct download -Solved

Posted: Sun Apr 19, 2020 3:49 pm
by Julien
Thomas Bredenfeld solved this topic after I fowarded it onto Pano2VR Users Group with Facebook.

I'm forwarding his solution and his script.
As it may be handy for others, i've just modified a script i'm using for stuff like this and set up a little helper file for what you need, Julien.

how to use it:
• unzip and put »download.php« into your folder e.g. »download«
• add folder »download« to your assets in the output panel under »advanced«
• put all stuff you need to be forced downloadable in the folder »download«
• instead of setting your download URL to »yourtoursite.com/assets/downloads/mydownload.pdf« set it to »yourtoursite.com/assets/downloads/download.php?file=mydownload.pdf«

»download.php« is meant to work with files in its own folder only.

only requirement is PHP running on your server, but as you're using wordpress, this is guaranteed ;-)

hope this works and helps ...
From my side when writing the topic, I was pretty sure that my enquiry was related to P2VR itself, and not something extra related to the webserver or so :roll: My experience with web, php and so, is limited.
Thanks again Thomas Bredenfeld

Julien

Re: Assets, media file and direct download -Solved

Posted: Thu May 21, 2020 3:51 pm
by Norris Design
Julien-
I was glad to find this thread, but I must be missing a step or something…

First off the way we upload it to our website is by uploading the whole ggpkg so maybe that’s it? We use wordpress also

Anyway, I downloaded the zip, made a “downloads” folder within the “assets” folder

Where do I put the “download.php”? Inside the assets folder? Any ideas what I’m missing?

Of course I can make a button that takes me to a landing page, but I’m wanting to do what you accomplished!
Thanks

Re: Assets, media file and direct download -Solved

Posted: Thu May 21, 2020 5:24 pm
by Hopki
Hi Guys,
If you want to download then just zip it up and use a Go-To URL action pointing to the zip file.
Or you can add this tag into a text box to force download the PDF.

Code: Select all

<a href="assets/test.pdf" download > Download my PDF </a>
Of if you want to click a button and not download from a hyperlinked text in a text box you can do this.
Add a text box to the skin and in the text field enter:

Code: Select all

<a href="assets/test.pdf" download id="pdf_1"> Download my PDF </a>
Note the ID, pdf_1.

Then hide the text box.
In your Download button add a Go To URL action with the URL:

Code: Select all

javascript:document.getElementById("pdf_1").click();
Again note where the ID is located, pdf_1 in the above code.
This will now call the "herf" call from the text box.

You can add as many as you need but make sure the ID's are different.
Regards,

Re: Assets, media file and direct download -Solved

Posted: Thu May 21, 2020 7:11 pm
by Norris Design
Thanks for the help as always!!
I've gotten this to work where it downloads the content with a click!

I was hoping to make it so I didn't have to create a button for each image to download separately at the different nodes (and maybe you don't but I can't figure it out)

this project has been a humbling experience

Re: Assets, media file and direct download -Solved

Posted: Tue May 26, 2020 10:26 pm
by Norris Design
Something must be getting lost when it uploads to the website in the ggpkg

When I test locally it downloads perfectly fine, but when it's uploaded and I click the button it tells me "filename.htm" Failed - No File