Jump to content

upload script questions


Zuggy

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.