Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1055825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:37:22+00:00 2026-05-16T17:37:22+00:00

I am using Uploadify to Upload the Images. the only glitch i am facing

  • 0

I am using Uploadify to Upload the Images. the only glitch i am facing is i want to restrict the image dimension to the user for uploading the image. (I do not want to use the image resize for some reason). my logic for doing that in php is i have a user defined function which will take three parameters first the image tempname, second the width of the image to restrict, third the height of the image to restrict the user.

my function is something like this.

function valid_image($image, $width, $height = 0) {
             /** Get the Dimensions of the Uploaded Image **/
            list($image_width, $image_height) = getimagesize($image['tmp_name']);
            /** If the height parameter in function is skipped then perform this **/
        if( $height == '0') {
        if( $image_width !== $width) {
            return false;
            }
            }
            /** If all the parameters in the function has got the value then perform this **/
    else if($image_width !== $width || $image_height !== $height) {
            return false;
            }
            return true;
            }

i want to apply the same rule for uploadify.

here is my Jquery Script for Uploadify.

//Uploadify File1
  $(document).ready(function() {
    $('#nstitle').uploadify({ 
      'uploader': 'images/uploadify.swf',
      'script': 'uploadify.php',
      'folder': 'upload',
      'auto' : 'true',
      'cancelImg': 'images/cancel.png',
      'fileDesc': 'jpg/jpeg',
      'displayData': 'percentage',
      'fileExt': "*.jpg;*.jpeg",
      'sizeLimit' : '8388608',
      'fileDataName' : 'nstitle',
      onComplete: function(event, queueID, fileObj, response, data) 
      {
     $('#t_fileUploadName').append('<p>'+response+'<p/>');
     $("#t_fileUploadField").append("<input type='hidden' name='nstitle' value='" + response + "' />"); 
     $("#t_fileUploadBtn").remove();
      }
      }); }); 

now i want uploadify to generate the error if it does not satisfy the condition for that in uploadify.php i did something like this.

if (!empty($_FILES['nstitle'])) {
    $tempFile = $_FILES['nstitle']['tmp_name'];
    if(!valid_image($_FILES['nstitle'],685 , 50)) {
    echo "Incorrect File Dimension";
    die();
    }
    else {
    $targetPath = 'uploads/news/title/';
    move_uploaded_file($tempFile,$targetPath.$ns_title);
    echo "$targetPath$ns_title";
    }
}

Please Note that i have included all related file to the respective pages with require_once(); if i remove that valid_image() and run the script without it it just work perfectly fine, but if i try to put on a condition to trigger the error it does not work because i tried uploading the file with exact dimension. and still it refuses to enter that else condition.

i am going blank here, is this the wrong way of doing it. if yes then how do i restrict the user to fixed image dimension. any type of help is highly appreciated let me know your take and experience using Uplodify related to triggering the error.

thanks in advance..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:37:23+00:00Added an answer on May 16, 2026 at 5:37 pm

    Change

    if(!valid_image($_FILES['nstitle'],685 , 50)) {
    

    into

    if(!valid_image($tempFile,685 , 50)) {
    

    Seems you’ve been working for too long that you didn’t catch this tiny mistake 🙂 seems I was the one working for too long..


    EDIT:

    At the top of your valid_image function, add:

    var_dump($image, getimagesize($image['tmp_name']));
    

    What does that output?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Uploadify to upload some images with ASP.NET. I use Response.WriteFile() in ASP.NET
I am using struts to build an image uploading module. However, I am encountering
I am using uploadify along with ASP.NET to upload files to my server. At
I'm using a small site to experiment with the uploading of pictures and displaying
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I looked at this question: Uploading multiple files with Django but it did not
We are using PHP with CodeIgniter to import millions of images from hundreds of
I am new to iphone app development, and I am trying to upload images
Using online interfaces to a version control system is a nice way to have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.