I use this PHP code for uploading audio(mp3) file from Flash AS3 to server. It works when a file upload from html form but it doesn't work when the file upload from AS3 side. When I remove *$_FILES['Filedata']['type']=='audio/mpeg'* condition it also work with AS3. I don't know what is the problem.
<?php
if($_FILES['Filedata']['size'] < 500000 && $_FILES['Filedata']['type']=='audio/mpeg'){
$uploads_dir = './upload/';
if( $_FILES['Filedata']['error'] == 0 ){
if( move_uploaded_file( $_FILES['Filedata']['tmp_name'],
$uploads_dir.$_FILES['Filedata']['name'] ) ){
echo 'ok';
exit();
}
}
echo 'error';
exit();
}else
exit();
?>
echo $_FILES['Filedata']['type'];
andecho $_FILES['Filedata']['size'];
above theif
statement and see what it outputs. – Amal Muraliecho
statement? – Amal Murali$_FILES
array is sent by client. Attacker can easily send malicious php file with typeaudio/mpeg
and take over your server. You have to check uploaded file on server side and make sure they are stored in non-executable form. – dev-null-dweller