get image size before upload image php

前端 未结 4 1943
余生分开走
余生分开走 2021-01-25 08:36

I want to know the image size in mb but before ulpload do the same. I have:

$errors =       array();
$image =        $_FILES[\'image\'][\'name\'];
$file_tmp =            


        
相关标签:
4条回答
  • 2021-01-25 09:12

    Can't you use the function filesize()?

    filesize($_FILES['image'])
    

    or

    filesize(//enter image url);
    

    I would give you more details but the php.net site is having malware problems

    0 讨论(0)
  • 2021-01-25 09:15

    Use php filesize function.You can get the bytes of the file

    $imgsize = filesize( '/home/projects/site/1.jpg' ); 
    
    0 讨论(0)
  • 2021-01-25 09:29

    Before upload you can check like so:

    $file_tmp = $_FILES['image']['tmp_name'];
    $size = filesize($file_tmp);
    

    But do you realize you are expecting the image to be less than a kilobyte in your code example?

    0 讨论(0)
  • 2021-01-25 09:31

    Well the plugin will help you : jQuery-File-Upload

    0 讨论(0)
提交回复
热议问题