Well I know how to upload image (.gif, .jpg, etc) resized, resample, add link to database fetch link and display images on webpage.

But now I need to be able to upload documents on server, add link in the database and be able to display those documents on the web, so is there any special requirements for that, specific mime type to be able to upload, and when you retrieve is it possible to either show a link that will open the document in the browser and/or open the download dialog box?

Any basic script that I can modify to my needs would be greatly appreciated.

Member Avatar for diafol

You can check mime types or file extensions.

http://en.wikipedia.org/wiki/Internet_media_type#Type_application

http://php.net/manual/en/function.finfo-file.php

http://php.net/manual/en/function.pathinfo.php

You can do your tests on the temp file ($_FILES['...']['tmp_name'])

Once you successfully move an allowed tmp file to your uploads folder, just add a record to the DB. Include all the relevant data you think is impt.
If you don't want to store info in the DB, you can run various info retrieving functions dynamically, but there seems little point to this.

You can indeed show a link - built from the DB info held in the DB. If the mime type can't be handled by the browser, it'll download (I think!).

Thanks diafol with the resources provided I got it to work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.