Hi i have site and a big problem i use CakePHP v1.2 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> PHP:
the code you posted is javascript it means you can't process the limit by pixels, you need to do it via the server-side. because javascript has no ability to check the dimensions of the image or file to be uploaded.. what you can do is start the upload process and once the file/image has been uploaded, you can check the dimensions of it via getimagesize function
Since the server error is most likely caused by the file size being too large, check the file size, not the number of pixels.