Đang chuẩn bị liên kết để tải về tài liệu:
Tạo mạng xã hội với PHP - part 27

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

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. | 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 www.eBookTM.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 www.eBookTM.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 table parent save grab .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.