Zuggy Posted June 21, 2007 Share Posted June 21, 2007 I'm fairly new to php and I'm trying to create and upload script that will upload a file to the server and then insert the location into the database. Example: If the location is www.bobroxorz.com I want to be able to insert www.bobroxorz.com/upload/random.pdf to the database. I want to make it so that I can use this script on several sites without having to change the code. I read that you can use $_SERVER['DOCUMENT_ROOT'] but when I tested it with an echo statement to see what I got all I got was an undefined index error. The actual uploading to the server works just fine. Also on a side note, so I'm not making multiple posts, Is there a more secure way of checking a files mime-types so that I'm not relying on the html because that can be faked. Example: with html (only allows .pdf): test.htm doesnt upload test.htm.pdf does upload. What I need is neither to be uploaded because it wouldnt take much for malwarex.exe to be uploaded as malwarex.exe.pdf. I read that there is a pear extension but that requires a server restart and the project I'm working on doesn't allow a restart of the production server so I don't want to rely on it while developing. Quote Link to comment https://forums.phpfreaks.com/topic/56553-upload-script-questions/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.