
Originally Posted by
sen01dj
but this is not work
When asking about code, be explicit about the behavior you expect and the behavior you get. "It doesn't work" tells us nothing.
If you can, use something like Fileinfo to identify file type.
An associative array is more efficient and (IMO) easier to read than a series of string comparisons.
PHP Code:
$allowed = array('audio/mpeg'=>1, 'audio/mp3' => 1, 'audio/mpeg3' => 1, 'video/mpeg' => 1, ...);
...
if (isset($allowed[$_FILES["file"]["type"]])) {
...
} else {
echo "Invalid file";
}
Note the official MIME type for mp3 files is "audio/mpeg", not "audio/mpeg3". You might want to include all possible types, following Postel's law.
When posting source code, embed it in [php], [html] or [code] tags.

Originally Posted by
taha116
Gona ask a side question... How can u make sure that it dosent have a virus when its being uploaded? is there a way besides like quarintening and scaning every time somthin is uploaded
Don't threadjack.
The free x10 servers have ClamAV installed, but seemingly don't have a way of invoking it from most scripting languages (an extension such as php-clamavlib or via a system() call). It's possible that ClamAV is already set up to scan uploaded files, but this requires more research.
You could write a CGI shell script to scan a file and invoke that, but it would be tricky to do securely. Even then, the shell invoked by CGI scripts is limited and may not be able to run ClamAV. Alternatively, quarantine new files and run a batch scan as a cron job, deleting or unquarantining files as appropriate.
Does anyone else know of another way for a script to invoke ClamAV from a script?