Php 在uploadify中限制图像上载

Php 在uploadify中限制图像上载,php,html,Php,Html,我正在使用uploadify上传图像。是否有任何方法限制用户上传宽度:670px高度:200px的图像以外的图像。 这是我的uploadify.php代码 <?php require_once("includes/connection.php"); $targetFolder = '/workbench/sudeepc/photogallery/uploads' ; if (!empty($_FILES)) { $tempFile = $_FILES['Filedata'][

我正在使用uploadify上传图像。是否有任何方法限制用户上传宽度:670px高度:200px的图像以外的图像。 这是我的uploadify.php代码

<?php
require_once("includes/connection.php");

$targetFolder = '/workbench/sudeepc/photogallery/uploads' ; 

if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
    $targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];

    // Validate the file type
    $fileTypes = array('jpg','jpeg','gif','png'); // File extensions
    $fileParts = pathinfo($_FILES['Filedata']['name']);

    if (in_array($fileParts['extension'],$fileTypes)) {
        move_uploaded_file($tempFile,$targetFile);

 $query="INSERT INTO `photo` ( `id` , `path` , `uname` )
 VALUES (
 '','${targetFile}', 'testnn');";
 mysql_query($query,$connection);


    } else {
        echo 'Invalid file type.';
    }
}
?>

您无法限制实际上载-必须上载文件才能让服务器端逻辑测试其有效性-文件扩展名、尺寸等

有一个内置的PHP函数来确定图像大小-

函数的作用是:确定任何给定图像的大小 归档并返回尺寸以及文件类型和 在普通HTML IMG标记内使用的高度/宽度文本字符串,以及 对应的HTTP内容类型。

返回包含7个元素的数组。
索引0和1分别包含图像的宽度和高度

检查文件扩展名后,可以在图像上调用此函数,并根据需要测试其尺寸

以下是函数的输出示例-

Array ( 
  [0] => 84 // width
  [1] => 52 // height
  ... 
)

您无法限制实际上载-必须上载文件才能让服务器端逻辑测试其有效性-文件扩展名、尺寸等

有一个内置的PHP函数来确定图像大小-

函数的作用是:确定任何给定图像的大小 归档并返回尺寸以及文件类型和 在普通HTML IMG标记内使用的高度/宽度文本字符串,以及 对应的HTTP内容类型。

返回包含7个元素的数组。
索引0和1分别包含图像的宽度和高度

检查文件扩展名后,可以在图像上调用此函数,并根据需要测试其尺寸

以下是函数的输出示例-

Array ( 
  [0] => 84 // width
  [1] => 52 // height
  ... 
)