Jump to content

Recommended Posts

Hi,

 

I have put an upload field, for users so that they could upload an mp3.

with php, I have limited the size to 200kb, and I don't allow other extensions than .mp3

 

Is this enough security to have the file upload like this ?

The site will be a game site, and my experience in these cases tells me, a lot of kids will want to mess with the site or try to hack it ... That's why I'm asking.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/130238-suggestion-for-fileupload-security/
Share on other sites

Just make sure you validate everything about the file before you move it from temp.  Another thing you can do if the file doesn't need to be directly accessed (http://site.com/mp3/song.mp3) you can store it above the webroot.  That way if someone does somehow figure something out and get a malicious file uploaded, they can't access it to execute it on the server. 

 

I would also rename the file so they don't know which one is there's if they somehow get to a point where that would matter.  So if John uploads bad.php.mp3 I would rename it to 32423432.mp3. 

I am validating :

 

only .mp3 extension

only audio/mpeg  type

max 100kb

rename the original file name

 

But as the mp3 will be played in some pages, I can't store it in the webroot. so the can look at the page source and see their renamed file.

 

anything more I must done?

Am I running the safety standard codes in this case? most programmer do this only? (in positions like me)

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.