SMFHacks.com

Downloads System Pro => Support => Topic started by: shuban on September 30, 2019, 10:06:42 pm

Title: Ideas
Post by: shuban on September 30, 2019, 10:06:42 pm
I know that when a document is uploaded, such as .doc, the mod stores the file without the file extension. I am looking to implement a document reader, such as google docs to display the file as a preview. It is done by using an iframe:

Code: [Select]
<iframe src="https://docs.google.com/gview?url=https://WEBSITE-URL.com/to/doc/file.doc&embedded=true"></iframe>
So for this to work, I need to use: https://WEBSITE-URL.com/downloads/'.$context['downloads_file']['filename'].' BUT, $context['downloads_file']['filename'] excludes the file's actual extension type. Even if I add the extension, such as .doc to the end of the string, it will not work because obviously the file stored is extension-less.

What ideas do you have that can help me overcome this issue? Of course, I could always create a temporary file in another folder with the extension, but when files get too big, it'd slow down the server.
Title: Re: Ideas
Post by: SMFHacks on September 30, 2019, 10:17:28 pm
I guess you could do a another script that outputs the contents of a download file if you pass the id. Files are stored with extension for security reasons same reason that SMF stores attachmetns that way.
Title: Re: Ideas
Post by: shuban on September 30, 2019, 10:23:36 pm
such as the download link itself, right? I believe I tried that, but no dice. Unless you had another idea in mind.

I like that it's extension-less actually, it's a good deterrent from folder hackers
Title: Re: Ideas
Post by: SMFHacks on September 30, 2019, 10:25:18 pm
Like a file that gets the ID of file from smf_file table.  Then does db lookup finds the filename.

Then does an echo of file_get_contents to display the file or something similar.
Title: Re: Ideas
Post by: Diego Andrés on October 03, 2019, 09:29:22 pm
If you are putting these docs in a lone category you could also only set up this reader for that particular cat ID so you don't have to find the extension, you already know it's a doc
Title: Re: Ideas
Post by: shuban on October 03, 2019, 09:31:13 pm
I'm not following. The files are stored without extensions.
Title: Re: Ideas
Post by: Diego Andrés on October 03, 2019, 09:54:25 pm
I'm quite sure that if you add the original extension it'd work as a normal file.
Title: Re: Ideas
Post by: shuban on October 03, 2019, 10:19:06 pm
I'm quite sure that if you add the original extension it'd work as a normal file.

Tried that. Didn't work