tailieunhanh - PHP and MySQL Web Development - P118

PHP and MySQL Web Development - P118: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | Editing Content 557 This method is simple but often effective. The Web browser does not provide any text editing facilities beyond the cut-and-paste functionality of the operating system. However when you just need to make a small change for instance to correct a spelling mistake it s very fast to bring up the content and amend it. Similar to file upload the form data could either be written to a file or stored in a database. Databases Versus File Storage An important decision to make at an early stage is how the content will be stored after it has been uploaded into the system. Because we will be storing metadata alongside the story text we have chosen to put the text parts of the content into the database. Although MySQL is capable of storing multimedia data we choose to store uploaded images on the file system. As discussed in Part II Using MySQL using BLOB data in your MySQL database can reduce performance. We will just store the image filename in the database. Using the file system the IMG SRC tag can reference the image file directly as usual. When a large amount of data is being stored it is important to optimize your data store. Just as the database would require proper indexes to be efficient the file system will benefit greatly from a well thought out directory structure. An example of this can be seen in Figure . pictures ------a ------b -------c ------d x y z Figure This directory structure has been structured for file uploads. The file system in this case is split into directories representing the first character of each filename. 10 000 files would therefore be spread across 26 directories with around 400 files in each directory. This would be much quicker to access than 10 000 files all in one directory. It is worth pointing out that the filename used should be generated by the upload processing script to ensure that it is unique. The example in Figure .

TỪ KHÓA LIÊN QUAN