Results 1 to 6 of 6
Thread: PHP
Hybrid View
-
29th November 2012 13:28 #1
PHP
,
.
png,jpg,gif if . pdf . Else var_dump .HTML Code:<form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <label for="avatar">Choose an avatar:</label> <input type="file" id="avatar" name="avatar" /> <input type="submit" name="submit" value="Submit" /> </form>
Submit, .PHP Code:
if(isset($_POST['submit'])){
$avatar = $_FILES['avatar']['name'];
$avatar_type = $_FILES['avatar']['type'];
// var_dump($avatar_type);
if($avatar_type == 'image/gif' || $avatar_type=='image/png' || $avatar_type=='image/jpg'){
echo 'Supported format';
}else{
echo 'Not supported format';
}
}
, .
-
29th November 2012 13:41 #2Registered User
Join Date: Nov:2008
Location: Sofia
Posts: 97
-
29th November 2012 13:59 #3
, , , pdf 10 var_dump($avatar_type) , pdf e 10 var_dump($avatar_type) string '' (length=0).
-
29th November 2012 14:11 #4
, . - . php.ini post_max_size upload_max_filesize.
Fujistu Lifebook E756 | Core i7-6500U / 400MHz-3.1GHz | 8 GB DDR4-2133 | Samsung PM871 / 256 GB SSD | 15" 1920x1080 | Manjaro Linux + kernel 4.19
-
29th November 2012 14:19 #5Registered User
Join Date: Nov:2008
Location: Sofia
Posts: 97
, type , type( ). 10 100% , 10 .
:
http://davidwalsh.name/php-file-extension
-
29th November 2012 16:29 #6Registered User
Join Date: Jul:2005
Location: Sofiq
Posts: 2,798
. IE . http://php.net/manual/en/function.finfo-file.php . , (Nginx, Apache, ...) PHP php.ini.




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in