PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1845
Number of posts: 5013

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
how to set limit for uploaded photo in PIXEL Posted by FeGan on 3 Dec 2011 at 8:47 AM
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?

<!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>

Report
Re: how to set limit for uploaded photo in PIXEL Posted by jivko790 on 9 Dec 2011 at 11:24 AM
how i creat nice web sait by cms?escort agency i need
Report
Re: how to set limit for uploaded photo in PIXEL Posted by ella818 on 5 Feb 2012 at 6:07 AM
To learn php is a hard work, is there anybody who can help me?
best stock
Report
Re: how to set limit for uploaded photo in PIXEL Posted by jivko790 on 9 Dec 2011 at 11:36 AM
how to do one nice hearder can some one help me

Escort Berlin

Escorts Munich

Escorts Berlin

Escorts Rotterdam

Escort Amsterdam
Report
Re: how to set limit for uploaded photo in PIXEL Posted by paulinetaylor8 on 29 Oct 2012 at 4:48 AM
You will implement an advanced upload plugin that can help client-side resizing capacity. http://wordpress.org/extend/plugins/wplupload/



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.