I'm curious what you think about the performance of your CMS. I noticed it has a page timer in the tail of the page source, which on my server (for the Contact page), hits .7s. That's actually pretty high to load a Contact page.
Do you have any official recommendations for improving performance with your CMS?
While I wait for your reply, I'm off to test cake's native caching functionality :-D
EDIT: Changing the core config to use Memcache instead of file caching, resulted in initial page loading in .85s, and subsequent loads at .55s, so that helps. Still seems quite high, as I'm used to .01-.1s load times :-)
Has anyone successfully uploaded pdf files consistently? I have a strange experience. Some pdf files I have no problem uploading while others just do not seem to go well. There was no error but when I check the folder, the files were not there. The same pdf files can be repeatedly uploaded and likewise the same pdf files do not upload repeatedly. As far as I can tell from the file names, they look the same. And yet one may upload while the other just do not.
I was using "application/pdf", "application/x-pdf" as the allowable types. And I'm using FileUpload without a model.
I created an application last week, specifically for uploading PDFs (using the FileUpload component plus a model).
The only issue I had, was in the lack of error verbosity at the time, as it turned out some PDFs would upload, others wouldn't, with no error. I found that some PDFs were exceeding the max upload size in php.ini, so I increased the allowable size, and made modifications to FileUpload to be more verbose regarding such errors.
Make sure you're using the latest copy of FileUpload from Nick's download page, as it has the more verbose error handling included.
Encountered an error where the uploaded file was too large, but FileUpload didn't toss any verbose errors. This remedies that issue.
Add the following array to the top of the FileUpload class: /**
* Definitions of errors that could occur during upload
*
* @var array
*/
var $upload_errors = array(
UPLOAD_ERR_OK => 'There is no error, the file uploaded with success.',
UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini.',
UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.',
UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded.',
UPLOAD_ERR_NO_FILE => 'No file was uploaded.',
UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder.', # Introduced in PHP 4.3.10 and PHP 5.0.3.
UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk.', # Introduced in PHP 5.1.0.
UPLOAD_ERR_EXTENSION => 'File upload stopped by extension.' # Introduced in PHP 5.2.0.
);
Then replace the function _checkFile() with this code: /***************************************************
* Checks if there is a file uploaded
*
* @return void
* @access protected
*/
function _checkFile(){
if($this->uploadedFile && $this->uploadedFile['error'] == UPLOAD_ERR_OK ) {
return true;
} else {
$this->_error($this->upload_errors[$this->uploadedFile['error']]);
return false;
}
}
Modified processFile() to allow saving of additional fields.
I use this component in DocumentsController, which has the model Document.
In DocumentsController::beforeFilter(), set the model to 'Document'.
The Document model must be prepared to accept the 'name', 'type', 'size' variables that FileUpload already saves to the database.
In your view where you submit a file (in the Document view files), you can now add additional inputs that you want to have saved via your Document controller.
Only 2 lines were changed (1 change 1 add): $save_data = $this->data[$this->fileModel];
unset($save_data['file']);
The full FileUpload::processFile() method is below. function processFile(){
$up_dir = WWW_ROOT . $this->uploadDir;
$target_path = $up_dir . DS . $this->uploadedFile['name'];
$temp_path = substr($target_path, 0, strlen($target_path) - strlen($this->_ext())); //temp path without the ext
//make sure the file doesn't already exist, if it does, add an itteration to it
$i=1;
while(file_exists($target_path)){
$target_path = $temp_path . "-" . $i . $this->_ext();
$i++;
}
Do you have any official recommendations for improving performance with your CMS?
While I wait for your reply, I'm off to test cake's native caching functionality :-D
EDIT: Changing the core config to use Memcache instead of file caching, resulted in initial page loading in .85s, and subsequent loads at .55s, so that helps. Still seems quite high, as I'm used to .01-.1s load times :-)
Great job!
I assume Google Code Issues is where we report any errors, glitches, etc?
http://code.google.com/p/croogo/issues/list
I created an application last week, specifically for uploading PDFs (using the FileUpload component plus a model).
The only issue I had, was in the lack of error verbosity at the time, as it turned out some PDFs would upload, others wouldn't, with no error. I found that some PDFs were exceeding the max upload size in php.ini, so I increased the allowable size, and made modifications to FileUpload to be more verbose regarding such errors.
Make sure you're using the latest copy of FileUpload from Nick's download page, as it has the more verbose error handling included.
Add the following array to the top of the FileUpload class:
/**
* Definitions of errors that could occur during upload
*
* @var array
*/
var $upload_errors = array(
UPLOAD_ERR_OK => 'There is no error, the file uploaded with success.',
UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini.',
UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.',
UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded.',
UPLOAD_ERR_NO_FILE => 'No file was uploaded.',
UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder.', # Introduced in PHP 4.3.10 and PHP 5.0.3.
UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk.', # Introduced in PHP 5.1.0.
UPLOAD_ERR_EXTENSION => 'File upload stopped by extension.' # Introduced in PHP 5.2.0.
);
Then replace the function _checkFile() with this code:
/***************************************************
* Checks if there is a file uploaded
*
* @return void
* @access protected
*/
function _checkFile(){
if($this->uploadedFile && $this->uploadedFile['error'] == UPLOAD_ERR_OK ) {
return true;
} else {
$this->_error($this->upload_errors[$this->uploadedFile['error']]);
return false;
}
}
I use this component in DocumentsController, which has the model Document.
In DocumentsController::beforeFilter(), set the model to 'Document'.
The Document model must be prepared to accept the 'name', 'type', 'size' variables that FileUpload already saves to the database.
In your view where you submit a file (in the Document view files), you can now add additional inputs that you want to have saved via your Document controller.
Only 2 lines were changed (1 change 1 add):
$save_data = $this->data[$this->fileModel];
unset($save_data['file']);
The full FileUpload::processFile() method is below.
function processFile(){
$up_dir = WWW_ROOT . $this->uploadDir;
$target_path = $up_dir . DS . $this->uploadedFile['name'];
$temp_path = substr($target_path, 0, strlen($target_path) - strlen($this->_ext())); //temp path without the ext
//make sure the file doesn't already exist, if it does, add an itteration to it
$i=1;
while(file_exists($target_path)){
$target_path = $temp_path . "-" . $i . $this->_ext();
$i++;
}
$save_data = $this->data[$this->fileModel];
unset($save_data['file']);
if(move_uploaded_file($this->uploadedFile['tmp_name'], $target_path)){
//Final File Name
$this->finalFile = basename($target_path);
$model =& $this->getModel();
$save_data[$this->fields['name']] = $this->finalFile;
$save_data[$this->fields['type']] = $this->uploadedFile['type'];
$save_data[$this->fields['size']] = $this->uploadedFile['size'];
if(!$model || $model->save($save_data)){
$this->success = true;
}
else{
$this->success = false;
}
}
else{
$this->_error('FileUpload::processFile() - Unable to save temp file to file system.');
}
}