/** * A generic upload action for creating new images and saving them * with tags, not not associating with any object. * * A straight forward add to pool action. Written to allow integration with other plugins * or uploading contexts which don't involve the admin gen and an sfImagePoolImage form. * Handles multiple files, all with same tags. Good for WYSIWYG editor integration. * * Checks for a 'tag' field name and uses this to add tags. Can be * a CSV list or a single string. * * Only works with POST data, doesn't aim to replace any data (PUT). */ public function executeUpload(sfWebRequest $request) { $this->forward404Unless($request->isMethod('post')); // process each upload one by one foreach ($request->getFiles() as $upload) { // first do checks for standard php upload errors, as we probably won't have // an uploaded file to deal with at all, so need the correct error message. $errors = sfImagePoolUtil::getUploadErrors($upload); // spit out any errors we've got and halt right here. if (count($errors)) { $message = sprintf('<ul><li>%s</li></ul>', implode('</li><li>', $errors)); return $this->renderText($message); } sfImagePoolUtil::createImageFromUpload($upload, $tags); } return sfView::NONE; }