• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP tmpfile函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中tmpfile函数的典型用法代码示例。如果您正苦于以下问题:PHP tmpfile函数的具体用法?PHP tmpfile怎么用?PHP tmpfile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了tmpfile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: show

 function show()
 {
     $folder = 'tmp/';
     if (isset($_REQUEST['qqfile'])) {
         $file = $_REQUEST['qqfile'];
         $path = $folder . $file;
         $input = fopen("php://input", "r");
         $temp = tmpfile();
         $realSize = stream_copy_to_stream($input, $temp);
         fclose($input);
         if ($realSize != $_SERVER["CONTENT_LENGTH"]) {
             die("{'error':'size error'}");
         }
         if (is_writable($folder)) {
             $target = fopen($path, 'w');
             fseek($temp, 0, SEEK_SET);
             stream_copy_to_stream($temp, $target);
             fclose($target);
             echo "{success:true, target:'{$file}'}";
         } else {
             die("{'error':'not writable: {$path}'}");
         }
     } else {
         $file = $_FILES['qqfile']['name'];
         $path = $folder . $file;
         if (!move_uploaded_file($_FILES['qqfile']['tmp_name'], $path)) {
             die("{'error':'permission denied'}");
         }
         echo "{success:true, target:'{$file}'}";
     }
 }
开发者ID:enieber,项目名称:adianti,代码行数:31,代码来源:TFileUploader.class.php


示例2: callWebService

function callWebService($url, $method, $data = "")
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    //curl_setopt($ch,CURLOPT_HEADER, 0);
    $fp = null;
    if ($method == "PUT") {
        curl_setopt($ch, CURLOPT_PUT, 1);
        $fp = tmpfile();
        fwrite($fp, $data);
        fseek($fp, 0);
        curl_setopt($ch, CURLOPT_INFILE, $fp);
        curl_setopt($ch, CURLOPT_INFILESIZE, strlen($data));
    } elseif ($method == "POST") {
        $post = array("data" => $data);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    } elseif ($method == "DELETE") {
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
    }
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($fp) {
        fclose($fp);
    }
    curl_close($ch);
    return array("code" => $httpCode, "content" => $response);
}
开发者ID:simonwolton,项目名称:WebService-Exercise,代码行数:28,代码来源:callWebService.php


示例3: create_tmp_file

function create_tmp_file($data)
{
    $tmp_file = tmpfile();
    fwrite($tmp_file, $data);
    rewind($tmp_file);
    return $tmp_file;
}
开发者ID:zachborboa,项目名称:php-curl-class,代码行数:7,代码来源:Helper.php


示例4: createTmpFile

 public static function createTmpFile($data)
 {
     $tmp_file = tmpfile();
     fwrite($tmp_file, $data);
     rewind($tmp_file);
     return $tmp_file;
 }
开发者ID:edwardstock,项目名称:php-curl-class,代码行数:7,代码来源:helper.inc.php


示例5: createTables

 private function createTables()
 {
     /* @var $entityManager \Doctrine\ORM\EntityManager */
     $entityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_zfcDatagrid');
     /* @var $cli \Symfony\Component\Console\Application */
     $cli = $this->getServiceLocator()->get('doctrine.cli');
     $helperSet = $cli->getHelperSet();
     $helperSet->set(new EntityManagerHelper($entityManager), 'em');
     $fp = tmpfile();
     // $input = new StringInput('orm:schema-tool:create --dump-sql');
     $input = new StringInput('orm:schema-tool:create');
     /* @var $command \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand */
     $command = $cli->get('orm:schema-tool:create');
     $returnCode = $command->run($input, new StreamOutput($fp));
     $phpArray = $this->getServiceLocator()->get('Zf2datatable.examples.data.phpArray');
     $persons = $phpArray->getPersons();
     $this->createData(new Person(), $persons);
     // $entityManager->f
     // fseek($fp, 0);
     // $output = '';
     // while (! feof($fp)) {
     // $output = fread($fp, 4096);
     // }
     // fclose($fp);
     // echo '<pre>';
     // print_r($output);
     // print_r($returnCode);
     // echo 'DONE!';
     // exit();
 }
开发者ID:renatosalvatori,项目名称:Zf2datatable,代码行数:30,代码来源:Doctrine2.php


示例6: testSettingServices

 public function testSettingServices()
 {
     $logger = new Mustache_Logger_StreamLogger(tmpfile());
     $loader = new Mustache_Loader_StringLoader();
     $tokenizer = new Mustache_Tokenizer();
     $parser = new Mustache_Parser();
     $compiler = new Mustache_Compiler();
     $mustache = new Mustache_Engine();
     $cache = new Mustache_Cache_FilesystemCache(self::$tempDir);
     $this->assertNotSame($logger, $mustache->getLogger());
     $mustache->setLogger($logger);
     $this->assertSame($logger, $mustache->getLogger());
     $this->assertNotSame($loader, $mustache->getLoader());
     $mustache->setLoader($loader);
     $this->assertSame($loader, $mustache->getLoader());
     $this->assertNotSame($loader, $mustache->getPartialsLoader());
     $mustache->setPartialsLoader($loader);
     $this->assertSame($loader, $mustache->getPartialsLoader());
     $this->assertNotSame($tokenizer, $mustache->getTokenizer());
     $mustache->setTokenizer($tokenizer);
     $this->assertSame($tokenizer, $mustache->getTokenizer());
     $this->assertNotSame($parser, $mustache->getParser());
     $mustache->setParser($parser);
     $this->assertSame($parser, $mustache->getParser());
     $this->assertNotSame($compiler, $mustache->getCompiler());
     $mustache->setCompiler($compiler);
     $this->assertSame($compiler, $mustache->getCompiler());
     $this->assertNotSame($cache, $mustache->getCache());
     $mustache->setCache($cache);
     $this->assertSame($cache, $mustache->getCache());
 }
开发者ID:baardbaard,项目名称:bb-twitterfeed,代码行数:31,代码来源:EngineTest.php


示例7: fromFile_exceed_buffer

 /**
  * @test
  */
 public function fromFile_exceed_buffer()
 {
     //Create a 10k temp file
     $temp = tmpfile();
     fwrite($temp, str_repeat("1", 10000));
     $meta_data = stream_get_meta_data($temp);
     $filename = $meta_data["uri"];
     /** @var LoopInterface $loop */
     $loop = \EventLoop\getLoop();
     $source = new FromFileObservable($filename);
     $result = false;
     $complete = false;
     $error = false;
     $source->subscribe(new CallbackObserver(function ($value) use(&$result) {
         $result = $value;
     }, function ($e) use(&$error) {
         $error = true;
     }, function () use(&$complete) {
         $complete = true;
     }));
     $loop->tick();
     $this->assertEquals("4096", strlen($result));
     $this->assertFalse($complete);
     $this->assertFalse($error);
     $loop->tick();
     $this->assertEquals("4096", strlen($result));
     $this->assertFalse($complete);
     $this->assertFalse($error);
     $loop->tick();
     $this->assertEquals("1808", strlen($result));
     $this->assertTrue($complete);
     $this->assertFalse($error);
 }
开发者ID:RxPHP,项目名称:RxStream,代码行数:36,代码来源:FromFileObservableTest.php


示例8: connect

 function connect($filename, $encode = "EUC-JP")
 {
     $allData = array();
     //一時ファイルを使い、一気に文字コード変換
     if (!file_exists($filename)) {
         return false;
     }
     if (!($fileData = file_get_contents($filename))) {
         return false;
     }
     $fileData = mb_convert_encoding($fileData, "UTF-8", $encode);
     // 一時ファイルに書き込み
     $handle = tmpfile();
     $size = fwrite($handle, $fileData);
     fseek($handle, 0);
     while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) {
         $line = array();
         foreach ($data as $val) {
             echo $val;
             $line[] = trim($val);
         }
         $allData[] = $line;
     }
     fclose($handle);
     if ($this->allData = $allData) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:aim-web-projects,项目名称:ann-cosme,代码行数:30,代码来源:DB_CSV.class.php


示例9: executeOnNodeDriver

 /**
  * Sends a command with arguments to NodeJS process
  * which executes and when done returns the response
  * to this driver if no errors occur a Array returns
  * 
  * @param string $action Command in NodeJS process
  * @return Array|Boolean|String
  * @throws NodeDriverException
  */
 private function executeOnNodeDriver($action)
 {
     $args = func_get_args();
     array_shift($args);
     $jsonString = json_encode(["command" => $action, "params" => $args]);
     $tmpHandle = tmpfile();
     fwrite($tmpHandle, $jsonString);
     $metaDatas = stream_get_meta_data($tmpHandle);
     $tmpFilename = $metaDatas['uri'];
     $execString = "node " . realpath(dirname(__FILE__) . '/../../../vendor/node/index.js') . ' ' . $tmpFilename;
     //debug($execString);
     try {
         $response = exec($execString, $output, $return_var);
     } catch (Exception $e) {
         //debug($e);
     }
     //debug($response);
     fclose($tmpHandle);
     if ($return_var != 0) {
         throw new NodeDriverException([$action, print_r($args, true), $response]);
     }
     try {
         $response = json_decode($response, true);
     } catch (Exception $ex) {
     }
     return $response;
 }
开发者ID:Teleservice,项目名称:cakephp-mssql-linux,代码行数:36,代码来源:Node.php


示例10:

 /**
  * Open the stream and return the associated resource.
  *
  * @param   string              $streamName    Stream name (here, it is
  *                                             null).
  * @param   \Hoa\Stream\Context  $context       Context.
  * @return  resource
  * @throws  \Hoa\File\Exception
  */
 protected function &_open($streamName, \Hoa\Stream\Context $context = null)
 {
     if (false === ($out = @tmpfile())) {
         throw new File\Exception('Failed to open a temporary stream.', 0);
     }
     return $out;
 }
开发者ID:Grummfy,项目名称:Central,代码行数:16,代码来源:Temporary.php


示例11: save

 /**
  * Save the file to the specified path
  * @return boolean TRUE on success
  */
 function save($path, $filename)
 {
     $input = fopen("php://input", "r");
     $temp = tmpfile();
     $realSize = stream_copy_to_stream($input, $temp);
     fclose($input);
     if ($realSize != $this->getSize()) {
         return false;
     }
     $target = fopen($path, "w");
     fseek($temp, 0, SEEK_SET);
     stream_copy_to_stream($temp, $target);
     fclose($target);
     //insert data into attachment table
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     $thumb_width = VmConfig::loadConfig()->get('img_width');
     $user_s =& JFactory::getUser();
     $user_id = $user_s->id;
     $product_vm_id = JRequest::getInt('virtuemart_product_id');
     $database =& JFactory::getDBO();
     $gallery = new stdClass();
     $gallery->id = 0;
     $gallery->virtuemart_user_id = $user_id;
     $gallery->virtuemart_product_id = $product_vm_id;
     $gallery->file_name = $filename;
     $gallery->created_on = date('Y-m-d,H:m:s');
     if (!$database->insertObject('#__virtuemart_product_attachments', $gallery, 'id')) {
         echo $database->stderr();
         return false;
     }
     // end of insert data
     return true;
 }
开发者ID:naka211,项目名称:compac,代码行数:39,代码来源:php.php


示例12: executeHttpPost

 public function executeHttpPost($url, $postData)
 {
     $curlHandler = curl_init();
     curl_setopt($curlHandler, CURLOPT_ENCODING, "gzip");
     curl_setopt($curlHandler, CURLOPT_URL, $url);
     curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curlHandler, CURLOPT_CAINFO, realpath(dirname(__FILE__)) . "/startssl.pem");
     // THE CRAPIEST THING I'VE EVER SEEN :
     $putData = tmpfile();
     fwrite($putData, $putString);
     fseek($putData, 0);
     curl_setopt($curlHandler, CURLOPT_POSTFIELDS, $postData);
     try {
         $body = curl_exec($curlHandler);
         if ($body == false) {
             throw new Exception("Unable to curl " . $url . " reason: " . curl_error($curlHandler));
         }
         $status = curl_getinfo($curlHandler, CURLINFO_HTTP_CODE);
         if ($status != 200) {
             throw new ScoopHttpNot200Exception($url, $body, $status);
         }
         curl_close($curlHandler);
         return $body;
     } catch (Exception $e) {
         curl_close($curlHandler);
         throw $e;
     }
 }
开发者ID:queer1,项目名称:Scoopit-PHP,代码行数:28,代码来源:ScoopCurlHttpBackend.php


示例13: provideNotEmptyTestData

 public function provideNotEmptyTestData()
 {
     self::$fileResource = tmpfile();
     $emptyCountable = new \ArrayObject();
     $countable = new \ArrayObject(['not', 'empty']);
     return [[null, false], ['', false], ['something', true], [0, false], [1, true], [false, false], [true, true], [[], false], [['not', 'empty'], true], [new \stdClass(), true], [$emptyCountable, false], [$countable, true], [self::$fileResource, true]];
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:7,代码来源:EntityTraitTest.php


示例14: generate

 public function generate($log)
 {
     global $db;
     $host = "ftp.mozilla.org";
     $hostpos = strpos($this->logURL, $host);
     if ($hostpos === false) {
         throw new Exception("Log file {$this->logURL} not hosted on {$host}!");
     }
     $path = substr($this->logURL, $hostpos + strlen($host) + strlen("/"));
     $ftpstream = @ftp_connect($host);
     if (!@ftp_login($ftpstream, "anonymous", "")) {
         throw new Exception("Couldn't connect to Mozilla FTP server.");
     }
     $fp = tmpfile();
     if (!@ftp_fget($ftpstream, $fp, $path, FTP_BINARY)) {
         throw new Exception("Log not available at URL {$this->logURL}.");
     }
     ftp_close($ftpstream);
     rewind($fp);
     $db->beginTransaction();
     $stmt = $db->prepare("\n      UPDATE runs_logs\n      SET content = :content\n      WHERE buildbot_id = :id AND type = :type;");
     $stmt->bindParam(":content", $fp, PDO::PARAM_LOB);
     $stmt->bindParam(":id", $log['_id']);
     $stmt->bindParam(":type", $log['type']);
     $stmt->execute();
     $db->commit();
     fclose($fp);
 }
开发者ID:rhelmer,项目名称:tbpl,代码行数:28,代码来源:RawGzLogDownloader.php


示例15: crudHttp

 public static function crudHttp($uri, $data, $header = array())
 {
     $ch = curl_init();
     if (isset($data['get']) && !empty($data['get'])) {
         $uri .= '?' . http_build_query($data['get']);
     }
     if (isset($data['post']) && !empty($data['post'])) {
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $data['post']);
     }
     if (isset($data['put']) && !empty($data['put'])) {
         $str = stripslashes(http_build_query($data['put']));
         $tmp_file = tmpfile();
         fwrite($tmp_file, $str);
         fseek($tmp_file, 0);
         curl_setopt($ch, CURLOPT_PUT, true);
         curl_setopt($ch, CURLOPT_INFILE, $tmp_file);
         curl_setopt($ch, CURLOPT_INFILESIZE, strlen($str));
     }
     if (isset($data['delete']) && !empty($data['delete'])) {
         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
         curl_setopt($ch, CURLOPT_POSTFIELDS, $data['delete']);
     }
     curl_setopt($ch, CURLOPT_URL, $uri);
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $r = curl_exec($ch);
     curl_close($ch);
     return $r;
 }
开发者ID:sinkcup,项目名称:choose-portal,代码行数:31,代码来源:FdHelperLib.php


示例16: testResource

 public function testResource()
 {
     $res = tmpfile();
     $in = new Insistence();
     $in->setSchema(['internalType' => 'resource'])->insist($res);
     $in->setSchema(['internalType' => ['resource', 'string']])->insist($res);
 }
开发者ID:sirn-se,项目名称:phrity-util-insistence,代码行数:7,代码来源:InsistenceTest.php


示例17: connectToSesame

function connectToSesame($url, $data = "", $del = "", $put = "")
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_MUTE, 1);
    if ($data != "" && $put != "YES") {
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, "{$data}");
    }
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', 'Authorization: Basic ' . 'bWV0YW1vcnBob3NpczptM3RhbTBycGgwc2lz'));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    //		curl_setopt(CURLOPT_USERPWD, '[metamorphosis]:[m3tam0rph0sis]');
    if ($del == "YES") {
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
    }
    if ($put == "YES") {
        //$data = http_build_query($data);
        $len = strlen($data);
        //	 $fh = fopen('php://memory', 'rw');
        //	     fwrite($fh, $data);
        //			rewind($fh);
        $putData = tmpfile();
        fwrite($putData, $data);
        fseek($putData, 0);
        curl_setopt($ch, CURLOPT_INFILE, $putData);
        curl_setopt($ch, CURLOPT_INFILESIZE, $len);
        curl_setopt($ch, CURLOPT_PUT, true);
    }
    $output = curl_exec($ch);
    curl_close($ch);
    if ($put == "YES") {
        fclose($putData);
    }
    return $output;
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:35,代码来源:mmplus.php


示例18: gettempfilehandle

 private function gettempfilehandle()
 {
     if (!$this->tempfilehandle) {
         $this->tempfilehandle = tmpfile();
     }
     return $this->tempfilehandle;
 }
开发者ID:laiello,项目名称:litepublisher,代码行数:7,代码来源:remote.ftp.class.php


示例19: output_word

function output_word($data, $fileName = '')
{
    if (empty($data)) {
        return '';
    }
    $data = '
        <html xmlns:v="urn:schemas-microsoft-com:vml"
        xmlns:o="urn:schemas-microsoft-com:office:office"
        xmlns:w="urn:schemas-microsoft-com:office:word"
        xmlns="http://www.w3.org/TR/REC-html40">
        <head><meta http-equiv=Content-Type content="text/html;  
        charset=utf-8">
        <meta name=ProgId content=Word.Document>
        <meta name=Generator content="Microsoft Word 11">
        <meta name=Originator content="Microsoft Word 11">
        <xml><w:WordDocument><w:View>Print</w:View></xml></head>
        <body>' . $data . '</body></html>';
    $filepath = tmpfile();
    $len = strlen($data);
    fwrite($filepath, $data);
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename={$fileName}.doc");
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . $fileName . '.doc');
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . $len);
    rewind($filepath);
    echo fread($filepath, $len);
}
开发者ID:iicc,项目名称:showdoc,代码行数:33,代码来源:function.php


示例20: generateRealImage

 /**
  * Generate real image.
  * @param resource $image
  * @param string $format
  * @return \App\Libraries\Image
  */
 private static function generateRealImage($image, $format)
 {
     $tempFile = tmpfile();
     $metaDatas = stream_get_meta_data($tempFile);
     $tmpFilename = $metaDatas['uri'];
     fclose($tempFile);
     switch ($format) {
         case Objects\Image::PNG:
             imagepng($image, $tmpFilename);
             break;
         case Objects\Image::JPG:
             imagejpeg($image, $tmpFilename);
             break;
         case Objects\Image::GIF:
             imagegif($image, $tmpFilename);
             break;
         default:
             $format = Objects\Image::PNG;
             imagepng($image, $tmpFilename);
             break;
     }
     $formatedFilename = $tmpFilename . "." . $format;
     @rename($tmpFilename, $formatedFilename);
     imagedestroy($image);
     return new Objects\Image($formatedFilename, $format);
 }
开发者ID:pehape,项目名称:text-image,代码行数:32,代码来源:TextImageRenderer.php



注:本文中的tmpfile函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP tmplInitializeInstance函数代码示例发布时间:2022-05-23
下一篇:
PHP tm_icon函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap