SMFHacks.com
Downloads System Pro => Support => Topic started 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:
<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.
-
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.
-
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
-
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.
-
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
-
I'm not following. The files are stored without extensions.
-
I'm quite sure that if you add the original extension it'd work as a normal file.
-
I'm quite sure that if you add the original extension it'd work as a normal file.
Tried that. Didn't work