I want to upload .mp3 file(only) from device to my server.
I want to browse path of media data and select any mp3 file and upload it.
Notice if you copy & paste the above PHP codes anyone could upload a malicious PHP script to your server and run it, always be aware of that, check the extensions SERVER SIDE with PHP there are thousands of examples here and in the web on how to do it. Also for extra security add rules to your apache, nginx server to add header Content-Disposition (jpg,png,gif,???) and to NOT parse PHP code on the upload folder.
in nxgin for example it would be something like this...
#add header Content-Disposition
location ^~ /upload/pictures {
default_type application/octet-stream;
types {
image/gif gif;
image/jpeg jpg;
image/png png;
}
add_header X-Content-Type-Options 'nosniff';
if ($request_filename ~ /(((?!\.(jpg)|(png)|(gif)$)[^/])+$)) {
add_header Content-Disposition 'attachment; filename="$1"';
# Add X-Content-Type-Options again, as using add_header in a new context
# dismisses all previous add_header calls:
add_header X-Content-Type-Options 'nosniff';
}
}
#do NOT parse PHP script on the upload folder
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
#if is the upload folder DO NOT parse PHP scripts on it
if ($uri !~ "^/upload/pictures") {
fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket;
}
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}