Archives
Recent posts
Recent comments
- In File uploading, file storage and CakePHPs MediaView class
- Rob Halff wrote: I think if you want to keep things manageable storing files in the database can be a very good...
- In File uploading, file storage and CakePHPs MediaView class
- sebb86 wrote: $this-set('path', APP . 'media' . DS . $media['Media']['path']); I think the path is only the...
- In File uploading, file storage and CakePHPs MediaView class
- sebb86 wrote: Hello again ;) Could you write an example for this? e.g.: link(... Thanks!
Categories
Words of Wisdom from Florian Krämer
-
Image saving and processing for high traffic sites
February 03 2012 | Florian Krämer | CakePHP, Uncategorized
I think everyone has already seen code similar like this: What's wrong with this? Let's assume you have an image library behind the Thumb helper. It will process the image supplied in $image. It will try to create the thumbnail, opening a file if it does not already exist at the destination and start processing the image. Once complete, it will write it out to the - as long as process takes - locked file. The issue with this is the race condition in which another user attempts to load the same page, before the initial image resize and write process has completed. The helper will do exactly as it is told, and attempt to create the image thumbnail as it doesn't yet exist. Consider a very busy site, and you can see that this would quickly bring a server to its knees. This is not as much of a problem when you have just a few visitors per day, or per hour. However, if you ...[ Read More | 0 Comments ]
-
File uploading, file storage and CakePHPs MediaView class
January 25 2010 | Florian Krämer | CakePHP, Uncategorized
This article includes how to upload and store files, because I've seen a lot of discussion about that too, but if you're just interested in how to use the MediaView class scroll down. Handling file uploads in CakePHP First let's start with the required form, to create a file upload form all you have to do is this: The "type" in the options of Form::create() takes post, get or file. To configure the form for file uploading it has to be set to file which will render the form as a multipart/form-data form. When you submit the form now, you'll get data like this in $this->data of your controller: Ok, now the big question with a simple answer is where the file data should be processed, guess where. Right – in the model because it's data to deal with and validation to do against it. Because it's a recurring task to upload files I suggest you to write a behaviour for it or conver...[ Read More | 0 Comments ]