public function __construct($url, $callback = null) { register_shutdown_function(array(&$this, "__destruct")); $options = array(CURLOPT_USERAGENT => sfConfig::get('app_version_name') . ' (' . sfConfig::get('app_version_rev') . ' ' . sfConfig::get('app_version_comment') . ') ' . sfConfig::get('app_version_url')); // todo abstact this out $this->original_url = $url; $original_name = preg_replace('#^.*/#', '', $this->original_url); // we'll need to do this for redirects fixme $this->b = $b = new disconnectedCurl($url, $options); // probably want to have a way to gather statistics here try { $b->run($callback); // we should HEAD this first } catch (Exception $e) { throw limeException::createFromException($e, 'curl'); } if ($b->isRunning()) { throw new limeException('curl', 'still running'); } $mime_type = $b->getHeader('Content-Type'); // of course we shouldn't trust people to have their servers configured right; sigh todo $mime_type = preg_replace('/;.*$/', '', $mime_type); // remove stuff after the semicolon delimiter "charset=UTF-8" etc parent::__construct($original_name, $mime_type, $b->getFile(), filesize($b->getFile())); }
/** * Constructor * * @param string $name * @param string $tmp_name * @param string $type * @param string $error * @param string $size * @param string $path: The directory where the uploaded file will be saved. * Default is null. $path might be delegated through * a whole form validation process, where all * instances of sfFilebasePluginUploadedFiles be * generated by the validator and files moved by * the orm-form instance. * */ function __construct($originalName, $type, $tempName, $size, $path = null, $error = null) { parent::__construct($originalName, $type, $tempName, $size, $path); if (empty($error)) { $this->error = self::UPLOAD_ERR_OK; } else { $this->error = $error; } if (empty($size) || empty($type)) { $tmp_file = sfFilebasePlugin::getInstance()->getFilebaseFile($tempName); if (empty($size)) { $size = $tmp_file->getSize(); $this->size = $size; } if (empty($type)) { $type = $tmp_file->getMimeType('application/octet-stream'); $this->type = $type; } } }