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 8571877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:52:45+00:00 2026-06-11T18:52:45+00:00

I am using Uploadify to upload image in php(codeigniter). Tested with the sample php

  • 0

I am using Uploadify to upload image in php(codeigniter). Tested with the sample php file that come with the uploadify package. It works. However, I can’t get onUploadError triggered. The sample php code has:

if (in_array($file_ext,$fileTypes)) {
    $newFileName = mt_rand() . time() . '.' . $file_ext;
    $targetFile = rtrim($targetPath,'/') . '/' . $newFileName;
    move_uploaded_file($tempFile,$targetFile);
    echo $newFileName;
} else {
    echo 'Invalid file type.';
}

js is very simple as following:

$('#file_upload').uploadify({
        'fileTypeDesc' : 'Image Files',
        'fileTypeExts' : '*.gif; *.jpg; *.jpeg; *.png',
        'swf'      : '/static/uploadify/uploadify.swf',
        'uploader'      : '/static/uploadify/uploadify.php',
        'onUploadError' : function(file, errorCode, errorMsg, errorString) {
            console.log('The file ' + file.name + ' errorCode ' + errorCode + ' errorMsg ' + errorMsg + ' errorString ' + errorString);
        },
        'onUploadSuccess' : function(file, data, response) {
            console.log(data);
        }
    });

when the Invalid file type. is echoed to the frontend. the onUploadSuccess is triggered instead of onUploadError. It seems odd to me that there is no indicator to stell uploadify there is an error from php.

the only way that triggers onUploadError is to set a non 200 http header before echoing. however, onUploadError function arguments errorCode, errorMsg, errorString are the http code and the echo content(error message) is lost.

UPDATES

I modified the question title so it speaks the real problem I was trying to solve. And I have since found the solution.

  • 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-06-11T18:52:46+00:00Added an answer on June 11, 2026 at 6:52 pm

    I finally got sometime to tackle this problem and here are my steps to solve it.

    first, the problem of onUploadError is not fired is because the file has been uploaded successfully

    second, uploadify queue limit and upload limit are updated accordingly upon successful upload regardless of detection of wrong image dimension from the backend.

    So the solution is that my backend checks image dimension and responds with a json data with error message which shown to user. also reset uploadify, really it is swfupload, variable successful_uploads. that makes sure the queuelimit or upload limit not messed up. sample code:

    'onUploadSuccess' : function(file, data, response) {
        var obj = eval('(' + data + ')');
        if ( obj.success ) { alert('uploaded') }
        else { 
            var stats = this.getStats();
            this.setStats({successful_uploads: stats.successful_uploads - 1});
        }
     }
    

    see swfupload setStats method http://demo.swfupload.org/Documentation/#setStats

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

Sidebar

Related Questions

I have been using to upload an image file from HTML5/JS and using PHP
I am using Jquery Uploadify for images upload with PHP, here i want to
I am using Jquery Uploadify for images upload with PHP, here i have multiple
here is a site http://www.lyrkjsw.gov.cn that can let the registered user to upload file
Living in 2012 I did not think a image upload using PHP would cause
I'm using this php code for an image upload. But I keep getting an
I am using this uploadify plugin . I am posting variables however everything works
I am using Uploadify to upload Files and using Codeigniter framework. Here is my
I am using Uploadify and class.upload.php for uploading and manipulating images. here are my
I'm using uploadify on a page that allows a user to upload images as

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.