Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'thiết kế mạng xã hội với php - 27', công nghệ thông tin, đồ họa - thiết kế - flash phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Statuses Other Media else invalid extention return false else not uploaded file return false The following getter method is used to return the name of the image we are working with Get the image name return String public function getName return this- name Finally we have our save method which again must detect the type of image to work out which function to use. Save changes to an image e.g. after resize @param String location location of image @param String type type of the image @param int quality image quality 100 return void public function save location type quality 100 type type this- type type if type IMAGETYPE_JPEG imagejpeg this- image location quality elseif type IMAGETYPE_GIF 242 Download from Wow eBook www.wowebook.com Chapter 8 imagegif this- image location elseif type IMAGETYPE_PNG imagepng this- image location Using the image manager library to process the file upload Now that we have a simple centralized way of processing file uploads and resizing them we can process the image the user is trying to upload as their extended status. Process an image upload and set the image @param String postfield the _POST field the image was uploaded through return boolean public function processImage postfield require_once FRAMEWORK_PATH . lib images imagemanager.class.php im new Imagemanager prefix time . _ if im- loadFromPost postfield this- registry- getSetting upload_path . statusimages prefix im- resizeScaleWidth 150 im- save this- registry- getSetting upload_path . statusimages . im- getName this- image im- getName return true else return false 243 Download from Wow eBook www.wowebook.com Statuses Other Media Saving the status This leaves us with the final method for saving the status. This calls the parent object s save method to create the record in the statuses table. Then it gets the ID and inserts a new record into the images table with this ID as the ID. Save the image status return void public function save save the parent object and thus the status .