php - Check JSON file when uploading -


i creating upload function want upload json file.

my json string inside file :{"name":"john"}

my php code:

$filetype = $_files['uploaded']['type']; if ($filetype != "application/json") {   print 'not valid json file'; } 

also tried:

$filetype = $_files['uploaded']['type']; if ($filetype != "text/json") {   print 'not valid json file'; } 

when trying upload json file shows me 'not valid json file' error.

plz me wrong code.

there no explicit file type set when creating *.json files. instead files mime-type going application/octet-stream, binary file, typically application or document has opened in application.

check array $_files['uploaded'] type.


Comments

Popular posts from this blog

How to logout from a login page in asp.net -

Stack level too deep error after upgrade to rails 3.2 and ruby 1.9.3 -