Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 3rd, 2011, 01:10 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question How to set limit fot uploaded photos size in PIXEL

Hi i have site and a big problem

site like pphotosharing site.when uploaded photos big 10.000 x 10.000 pixel then my site server downloaded and then Internal server error 500.i want to set MAX limit for uploaded photos in pixel.please help me

this is code.there seted limit to photo size in MB and more.how i set limit in pexels?

PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" version="-//W3C//DTD XHTML 1.1//EN" xml:lang="en">
<head>

...
  
  <?php if(array_key_exists('controller'$this->params) && $this->params['controller'] == 'upload'): ?>
    <?php echo $javascript->link('swfupload'?>
    <?php echo $javascript->link('swfupload.queue'?>
    <?php echo $javascript->link('swfupload.fileprogress'?>
    <script type="text/javascript">
    function fileQueued(file) {
      try {
        var progress = new FileProgress(file, this.customSettings.progressTarget);
        progress.setStatus("<?php echo ucfirst(__('pending'true)) ?>...");
        progress.toggleCancel(true, this);
      } catch (ex) {
        this.debug(ex);
      }

    }

    function fileQueueError(file, errorCode, message) {
      try {
        if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
          alert("You have attempted to queue too many files.\n" + (message === 0 ? "You have reached the upload limit." : "You may select " + (message > 1 ? "up to " + message + " files." : "one file.")));
          return;
        }

        var progress = new FileProgress(file, this.customSettings.progressTarget);
        progress.setError();
        progress.toggleCancel(false);

        switch (errorCode) {
          case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
          progress.setStatus("File is too big.");
          this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
          break;
          case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
          progress.setStatus("Cannot upload Zero Byte files.");
          this.debug("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
          break;
          case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
          progress.setStatus("Invalid File Type.");
          this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
          break;
          default:
          if (file !== null) {
            progress.setStatus("Unhandled Error");
          }
          this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
          break;
        }
      } catch (ex) {
        this.debug(ex);
      }
    }

    function fileDialogComplete(numFilesSelected, numFilesQueued) {
      try {
        if (numFilesSelected > 0) {
          document.getElementById(this.customSettings.cancelButtonId).disabled = false;
          $("finish_uploading_button").hide();
        }

        /* I want auto start the upload and I can do that here */
        this.startUpload();
      } catch (ex)  {
        this.debug(ex);
      }
    }

    function uploadStart(file) {
      try {
        /* I don't want to do any file validation or anything,  I'll just update the UI and
        return true to indicate that the upload should start.
        It's important to update the UI here because in Linux no uploadProgress events are called. The best
        we can do is say we are uploading.
        */
        var progress = new FileProgress(file, this.customSettings.progressTarget);
        progress.setStatus("<?php echo ucfirst(__('uploading'true)) ?>...");
        progress.toggleCancel(true, this);
      }
      catch (ex) {}

      return true;
    }

    function uploadProgress(file, bytesLoaded, bytesTotal) {
      try {
        var percent = Math.ceil((bytesLoaded / bytesTotal) * 100);

        var progress = new FileProgress(file, this.customSettings.progressTarget);
        progress.setProgress(percent);
        progress.setStatus("<?php echo ucfirst(__('uploading'true)) ?>...");
      } catch (ex) {
        this.debug(ex);
      }
    }

    function uploadSuccess(file, serverData) {
      try {
        var progress = new FileProgress(file, this.customSettings.progressTarget);
        progress.setComplete();
        progress.setStatus("<?php echo ucfirst(__('uploaded'true)) ?>.");
        progress.toggleCancel(false);
      } catch (ex) {
        this.debug(ex);
      }
    }

    function uploadError(file, errorCode, message) {
      try {
        var progress = new FileProgress(file, this.customSettings.progressTarget);
        progress.setError();
        progress.toggleCancel(false);

        switch (errorCode) {
          case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
          progress.setStatus("Upload Error: " + message);
          this.debug("Error Code: HTTP Error, File name: " + file.name + ", Message: " + message);
          break;
          case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
          progress.setStatus("Upload Failed.");
          this.debug("Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
          break;
          case SWFUpload.UPLOAD_ERROR.IO_ERROR:
          progress.setStatus("Server (IO) Error");
          this.debug("Error Code: IO Error, File name: " + file.name + ", Message: " + message);
          break;
          case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
          progress.setStatus("Security Error");
          this.debug("Error Code: Security Error, File name: " + file.name + ", Message: " + message);
          break;
          case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
          progress.setStatus("Upload limit exceeded.");
          this.debug("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
          break;
          case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
          progress.setStatus("Failed Validation.  Upload skipped.");
          this.debug("Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
          break;
          case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
          // If there aren't any files left (they were all cancelled) disable the cancel button
          if (this.getStats().files_queued === 0) {
            document.getElementById(this.customSettings.cancelButtonId).disabled = true;
            $("finish_uploading_button").show();
          }
          progress.setStatus("<?php echo ucfirst(__('cancelled'true)) ?>");
          progress.setCancelled();
          break;
          case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
          progress.setStatus("<?php echo ucfirst(__('stopped'true)) ?>");
          break;
          default:
          progress.setStatus("Unhandled Error: " + errorCode);
          this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
          break;
        }
      } catch (ex) {
        this.debug(ex);
      }
    }

    function uploadComplete(file) {
      if (this.getStats().files_queued === 0) {
        document.getElementById(this.customSettings.cancelButtonId).disabled = true;
        $("finish_uploading_button").show();
      }
    }

    // This event comes from the Queue Plugin
    function queueComplete(numFilesUploaded) {
      var status = document.getElementById("divStatus");
      status.innerHTML = numFilesUploaded + " <?php echo ucfirst(__('file(s) uploaded'true)) ?>";
    }

    var swfu;

    window.onload = function() {
      var settings = {
        flash_url : "<?php echo $this->webroot ?>swf/swfupload.swf",
        upload_url: "<?php echo $html->url('/photos/upload?PHPSESSID=' session_id() . '&privacy=' $_GET['privacy'], true?>",   // Relative to the SWF file
        post_params: {},
        file_size_limit : "2 MB",
        file_types : "*.jpg;*.png;*.gif;*.bmp",
        file_types_description : "Photos or pictures",
        file_upload_limit : 10,
        file_queue_limit : 0,
        custom_settings : {
          progressTarget : "fsUploadProgress",
          cancelButtonId : "btnCancel"
        },
        debug: false,
...

        // The event handler functions are defined in handlers.js
        file_queued_handler : fileQueued,
        file_queue_error_handler : fileQueueError,
        file_dialog_complete_handler : fileDialogComplete,
        upload_start_handler : uploadStart,
        upload_progress_handler : uploadProgress,
        upload_error_handler : uploadError,
        upload_success_handler : uploadSuccess,
        upload_complete_handler : uploadComplete,
        queue_complete_handler : queueComplete  // Queue plugin event
      };

      swfu = new SWFUpload(settings);
    };
        </script>
      <?php endif ?>           
    </head>
    <body>
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i determine size of file being uploaded? kaos_frack Beginning PHP 3 January 10th, 2007 03:48 PM
XML SIZE LIMIT Tristany SQL Server 2005 7 September 14th, 2006 01:01 PM
Verifying uploaded File Size in Client-side Ushhh ASP.NET 1.0 and 1.1 Professional 5 August 30th, 2006 07:13 AM
Loading a jpg and determining the pixel size jaucourt Flash (all versions) 0 January 19th, 2005 07:09 AM



All times are GMT -4. The time now is 07:40 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.