2011-09-27 3 views
11

Bonjour J'ai besoin d'obtenir la hauteur et la largeur à la volée d'une image téléchargée.Obtenez la hauteur et la largeur de l'image PHP

Ceci est la fonction PHP J'utilise, mais il ne retourne rien pour la largeur et la hauteur ..

Pourriez-vous s'il vous plaît me aider?

list($width, $height, $type, $attr) = getimagesize($_FILES["Artwork"]); 
$min_width = "1000"; 
$min_height = "1000"; 
if ((($_FILES["Artwork"]["type"] == "image/gif") || ($_FILES["Artwork"]["type"] == "image/jpeg") || ($_FILES["Artwork"]["type"] == "image/jpg") 
|| ($_FILES["Artwork"]["type"] == "image/pjpeg")) && ($_FILES["Artwork"]["size"] < 20000000) && ($width > $min_width) && ($height > $min_height) && ($width == $height)) 
    { 


    if ($_FILES["Artwork"]["error"] > 0) 
    { 
    //echo "Return Code: " . $_FILES["Artwork"]["error"] . "<br />"; 


    }else{ 
     move_uploaded_file($_FILES["Artwork"]["tmp_name"], 
     $path_image . $imageName); 
     header("Location: http://pitchmystuff.co.uk/m/digidist/tracks/".$idAlbum.""); 
     } 



    }else{ 
    //echo "invalid file"; 

    echo '<script> 
    alert("There was an error uploading your coverart file. Please check the requirements and try again.'.$width.$height.'"); 
    document.location ="http://pitchmystuff.co.uk/m/digidist/albums/"; 
    </script>'; 


    } 
+4

'getimagesize()' est le ticket. Vous n'utilisez simplement pas la bonne variable comme paramètre. Il doit y avoir un message d'erreur à cet effet: Activer le rapport d'erreur pour le voir. –

+0

duplication possible de [Obtenir la hauteur et la largeur de l'image en tant que valeurs entières?] (Http://stackoverflow.com/questions/2179100/get-image-height-and-width-as-integer-values) –

Répondre

-1
<?php 
/*$size = getimagesize("http://heartbeatperformance.com.p9.hostingprod.com/customerphotos/photoes/51HDE3cnl2L.jpg"); 

list($width, $height) = $size; 
echo "width: $width<br />height: $height";*/ 



$testing = "http://heartbeatperformance.com.p9.hostingprod.com/customerphotos/img/logo.png"; 
//echo $testing; 
list($width, $height, $type, $attr) = getimagesize($testing); 
echo "Image width " . $width; 
echo "Image height " . $height; 



?> 
6
<?php 

$imagedetails = getimagesize($_FILES['Artwork']['tmp_name']); 
$width = $imagedetails[0]; 
$height = $imagedetails[1]; 

?> 
-1

$DOCS_NAME = $_FILES['DOCS']['name']; 
$DOCS_SIZE = getimagesize($_FILES['DOCS']['tmp_name']); 
$DOCS  = file_get_contents ($_FILES['DOCS']['tmp_name']); 
$FILE_SIZE = $_FILES["DOCS"]["size"]; 
$FILE_TYPE = $_FILES["DOCS"]["type"]; 

echo 'Width  = '.$DOCS_SIZE[0]. "<br />"; 
echo 'Height = '.$DOCS_SIZE[1]. "<br />";; 
echo '2   = '.$DOCS_SIZE[2]. "<br />";; 
echo '3   = '.$DOCS_SIZE[3]. "<br />";; 
echo 'bits  = '.$DOCS_SIZE['bits']. "<br />";; 
echo 'channels = '.$DOCS_SIZE['channels']. "<br />";; 
echo 'mime  = '.$DOCS_SIZE['mime']. "<br />"; 
echo 'type  = '.$_FILES["DOCS"]["type"]. "<br />"; 
echo 'size  = '.$_FILES["DOCS"]["size"]. "<br />"; 
Questions connexes