0

I'm creating an interactive website where the user can upload a file.All I want to do is how can I let the other users see this file? For example if some datas are saved into database I can make this using SELECT and then print these data. But if I have a file how can I make this file to be seen only (not downloaded) from users? So I just want to know what can I use to make this and don't want you to make this for me! So please if anyone has an ide please tell what should I learn to make this? Is it possible to save the file in a database in phpMyAdmin and to select then? If yes which is the type of the field I should use to save the file so varchar?

JAL
  • 39,073
  • 22
  • 153
  • 285
Doen
  • 33
  • 6
  • This depends on what type of file, what kind of content. – arkascha Jan 24 '16 at 17:09
  • A question: do you only want to show that there is a file, so its name , type and maybe size? Or do you want to show its content? – arkascha Jan 24 '16 at 17:10
  • Put the name of the files in a db when are uploaded then SELECT form db and echo it out – Mihai Jan 24 '16 at 17:13
  • Ask your self the same question again, but then display it using html-tags. – Skywalker Jan 24 '16 at 17:15
  • @arkascha I want to shiow its content – Doen Jan 24 '16 at 17:27
  • @Mihai I don't kno can I save this file into database? And if yes can I save the file in a new field ? – Doen Jan 24 '16 at 17:28
  • If you want to show its content, then it really depends on what type of file, so what type of content that is. Since different types of content have to be visualized completely different. – arkascha Jan 24 '16 at 17:36
  • Oh, that's not going to be easy. MS-Word documents are a mess of a format. Very few implementations exist that are able to make sense of it, probably none for the older, binary formats. For the newer will will get pretty good results using things like OpenOffice or LibreOffice. But whatever tool you use, you first have to create a toolchain to convert the content to some format that you can show in the web. You can _not_ simply somehow directly "show" the content of such a file. It will look like garbage. – arkascha Jan 24 '16 at 18:26
  • Maybe instead of creating all that yourself you want to take a look at a framework that is ready to be used and proven. It will save you tons of time to do so. I recomment the owncloud project for such task. They offer a pretty good web based system where you can plugin additional modules to. One module allows to display writer documents (what you call a "word document"). A decent job, a great product, an interesting project. Really, take a look. – arkascha Jan 24 '16 at 18:28

1 Answers1

0

It depends on how you want the file to be saved. If it's a text file I would go with text. If it's an image or some other kind of media I would pick blob. You can take a look at What are the differences between the BLOB and TEXT datatypes in MySQL? for more information on MySQL data types.

Another approach would be to save the file somewhere outside the database (in a directory tree somewhere) and save a filepath to that location in a varchar column. Many DBMS do not support group by on blob or clob columns so that is something to consider if portability is an issue, and it adds a layer of separation between your data and file storage.

Community
  • 1
  • 1
William Burnham
  • 4,234
  • 1
  • 13
  • 28