In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to identify document camouflage by PHP". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "PHP how to identify file camouflage"!
Question:
When uploading a file, you need to verify whether the uploaded file is legal. How to identify the file camouflage?
A simple test: directly change the txt file suffix to jpg; upload
Test Send this file:
1. Get the file suffix name through $_ FILES ['userfile'] [' type'];
$data = $_ FILES ['userfile']; var_dump ($data); / * * result * * / / * array (5) {["name"] = > string (8) "test.jpg" ["type"] = > string (10) "image/jpeg" ["tmp_name"] = > string (26) "/ private/var/tmp/phpfyE3EC" ["error"] = > int (0) ["size"] = > int (19)} * /
It was not detected.
two。 Use the pathinfo () function to get the information of the file path
$data = $_ FILES ['userfile']; / / var_dump ($data); var_dump (pathinfo ($data [' name'])); / * result * / / * array (4) {["dirname"] = > string (1) "." ["basename"] = > string (8) "test.jpg" ["extension"] = > string (3) "jpg" ["filename"] = > string (4) "test"} * /
It was not detected.
3.PHP 's extended fileinfo (needs to be installed and enabled)
$data = $_ FILES ['userfile']; $filename = $data [' tmp_name']; $finfo = finfo_open (FILEINFO_MIME_TYPE); / / returns the mime type. Available since PHP 5.3.0. $mimetype = finfo_file ($finfo, $filename); finfo_close ($finfo); var_dump ($mimetype); / * * result * / / string (10) "text/plain" so far, I believe you have a better understanding of "how PHP identifies file camouflage". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.