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

PHP file_save_data函数代码示例

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

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



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

示例1: file_upload

function file_upload($fileUrl, $file_path = "files")
{
    //echo $file_path;
    //	echo 's3://'.$fileUrl;
    $file_temp = file_get_contents('http://www.voteapps.com/' . $fileUrl);
    //print_r();
    //Saves a file to the specified destination and creates a database entry.
    if (!file_exists($public_path . '/apkfiles')) {
        drupal_mkdir($public_path . '/apkfiles');
    }
    $file_arry = file_save_data($file_temp, 's3://' . $fileUrl, FILE_EXISTS_REPLACE);
    //print_r($file_arry);
    //转存视频和图片
    if ($file_arry) {
        // echo "</br>上传成功...";
        return $file_arry;
    } else {
        //echo "</br>再次尝试上传...";
        $file_arry = file_save_data($file_temp, 's3://' . $fileUrl, FILE_EXISTS_REPLACE);
        if ($file_arry) {
            //清空视频
            //unlink($$fileUrl);
            //	echo "</br>上传成功...";
            return $file_arry;
        } else {
            //清空视频
            // unlink($$fileUrl);
            //	echo "</br>上传失败...";
            return $file_arry;
            //header('HTTP/1.1 500 Internal Server Error');
            //exit;
        }
    }
}
开发者ID:napoler,项目名称:t-drupal-module,代码行数:34,代码来源:appdl.php


示例2: testEmbedButtonIconUsage

 /**
  * Tests the embed_button and file usage integration.
  */
 public function testEmbedButtonIconUsage()
 {
     $this->enableModules(['system', 'user', 'file']);
     $this->installSchema('file', ['file_usage']);
     $this->installConfig(['system']);
     $this->installEntitySchema('user');
     $this->installEntitySchema('file');
     $this->installEntitySchema('embed_button');
     $file1 = file_save_data(file_get_contents('core/misc/druplicon.png'));
     $file1->setTemporary();
     $file1->save();
     $file2 = file_save_data(file_get_contents('core/misc/druplicon.png'));
     $file2->setTemporary();
     $file2->save();
     $button = array('id' => 'test_button', 'label' => 'Testing embed button instance', 'type_id' => 'embed_test_default', 'icon_uuid' => $file1->uuid());
     $entity = EmbedButton::create($button);
     $entity->save();
     $this->assertTrue(File::load($file1->id())->isPermanent());
     // Delete the icon from the button.
     $entity->icon_uuid = NULL;
     $entity->save();
     $this->assertTrue(File::load($file1->id())->isTemporary());
     $entity->icon_uuid = $file1->uuid();
     $entity->save();
     $this->assertTrue(File::load($file1->id())->isPermanent());
     $entity->icon_uuid = $file2->uuid();
     $entity->save();
     $this->assertTrue(File::load($file1->id())->isTemporary());
     $this->assertTrue(File::load($file2->id())->isPermanent());
     $entity->delete();
     $this->assertTrue(File::load($file2->id())->isTemporary());
 }
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:35,代码来源:IconFileUsageTest.php


示例3: save

 function save(FileMaterial $fileMaterial)
 {
     $wo = wechat_api_init_wechatobj();
     $file_content = $wo->getForeverMedia($fileMaterial->media_id);
     $file = file_save_data($file_content, 'public://' . $fileMaterial->name);
     dpm($file);
 }
开发者ID:sosyuki,项目名称:wechat,代码行数:7,代码来源:FileMaterialSave.php


示例4: file_save_file

 public static function file_save_file($src, $dest)
 {
     $data = file_get_contents($src);
     $file = file_save_data($data, $dest, FILE_EXISTS_REPLACE);
     $fid = $file->id();
     return $fid;
 }
开发者ID:318io,项目名称:318-io,代码行数:7,代码来源:WG.php


示例5: sunshine_build_css_cache

function sunshine_build_css_cache($css_files)
{
    $data = '';
    // Create the css/ within the files folder.
    $csspath = file_create_path('css');
    $orgpath = drupal_get_path('theme', 'sunshine') . '/css/';
    file_check_directory($csspath, FILE_CREATE_DIRECTORY);
    // Build aggregate CSS file.
    foreach ($css_files as $key => $file) {
        $contents = drupal_load_stylesheet($orgpath . $file, TRUE);
        // Return the path to where this CSS file originated from.
        $base = base_path() . $orgpath;
        _drupal_build_css_path(NULL, $base);
        // Prefix all paths within this CSS file, ignoring external and absolute paths.
        $data .= preg_replace_callback('/url\\([\'"]?(?![a-z]+:|\\/+)([^\'")]+)[\'"]?\\)/i', '_drupal_build_css_path', $contents);
    }
    // Per the W3C specification at http://www.w3.org/TR/REC-CSS2/cascade.html#at-import,
    // @import rules must proceed any other style, so we move those to the top.
    $regexp = '/@import[^;]+;/i';
    preg_match_all($regexp, $data, $matches);
    $data = preg_replace($regexp, '', $data);
    $data = implode('', $matches[0]) . $data;
    $checksum = md5($data);
    $filename_cache = 'sunshine.cache.css';
    // Create the CSS file.
    if (!file_exists($csspath . '/' . $filename_cache) || md5(file_get_contents($csspath . '/' . $filename_cache)) != $checksum) {
        // drupal_set_message('Sunshine CSS cache has been rebuilt.');
        file_save_data($data, $csspath . '/' . $filename_cache, FILE_EXISTS_REPLACE);
    }
    return $csspath . '/' . $filename_cache;
}
开发者ID:upei,项目名称:drupal6-cms,代码行数:31,代码来源:template.php


示例6: mylog

function mylog($data, $file_name)
{
    if (file_destination('public://log', FILE_EXISTS_ERROR)) {
        // The file doesn't exist. do something
        drupal_mkdir('public://log');
    }
    file_save_data(print_r($data, true), "public://log/{$file_name}", FILE_EXISTS_REPLACE);
}
开发者ID:318io,项目名称:318-io,代码行数:8,代码来源:easier.drupal.php


示例7: unhandleField

 public function unhandleField($entity_type, $field_type, $field_name, &$value)
 {
     if (!is_array($value)) {
         return;
     }
     if (!array_key_exists('url', $value)) {
         return;
     }
     if (!array_key_exists('original_path', $value)) {
         return;
     }
     if (!array_key_exists('uuid', $value)) {
         return;
     }
     if (!array_key_exists('uid', $value)) {
         return;
     }
     // Make sure a file doesn't already exist with that UUID.
     $entity = Entity::loadByUUID($value['uuid'], 'file');
     if ($entity) {
         $definition = $entity->definition;
     } else {
         // Make sure a file doesn't already exist with that URI.
         $query = db_select('file_managed', 'f');
         $query->addField('f', 'fid');
         $query->condition('f.uri', $value['original_path']);
         $query->range(0, 1);
         $result = $query->execute()->fetch();
         if ($result) {
             $entity = Entity::load($result->fid, 'file');
             if ($entity) {
                 $definition = $entity->definition;
             }
         }
     }
     // If we haven't found the file yet, upload it.
     if (!isset($definition)) {
         // Decode the contents of the file.
         $contents = file_get_contents($value['url']);
         if ($contents === false) {
             throw new FileHandlerException('There was an error fetching the contents of the file.');
         }
         // Save the file.
         $file = file_save_data($contents, $value['original_path']);
         if (!$file || !$file->fid) {
             throw new FileHandlerException('There was an error saving the file to the database.');
         }
         $file->uuid = $value['uuid'];
         $file->uid = $value['uid'];
         file_save($file);
         $definition = $file;
     }
     // Don't completely reset the entity.
     foreach ((array) $definition as $key => $val) {
         $this->unresolved_definition->{$key} = $val;
     }
 }
开发者ID:sammarks,项目名称:publisher,代码行数:57,代码来源:FileHandler.php


示例8: saveTranslationRequest

 /**
  * Helper method for saving requests coming to POETRY mock.
  *
  * @param string $message
  *    XML request.
  */
 public static function saveTranslationRequest($message, $reference)
 {
     $path = TMGMT_POETRY_MOCK_REQUESTS_PATH . $reference . '.xml';
     $dirname = dirname($path);
     if (file_prepare_directory($dirname, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
         file_save_data($message, $path);
     } else {
         watchdog('poetry_mock', 'Unable to prepare requests directory', array(), WATCHDOG_ERROR);
     }
 }
开发者ID:ec-europa,项目名称:platform-dev,代码行数:16,代码来源:PoetryMock.php


示例9: testAdvertiserImages

 /**
  *
  */
 public function testAdvertiserImages()
 {
     // Download an example image from the internet.
     $test_data = file_get_contents('https://www.drupal.org/sites/all/modules/drupalorg/drupalorg/images/qmark-400x684-2x.png');
     // Save the file to the temporary scheme, let's save it as a .txt so the validation fails...
     $image_file = file_save_data($test_data, 'temporary://test_test_test.txt', FILE_EXISTS_REPLACE);
     $image_file_uri = $image_file->getFileUri();
     // Create an entity and set the image file..
     $entity = Advertiser::create(['advertiser_image' => $image_file_uri]);
     $violations = $entity->validate();
     $this->assertEqual(count($violations), 1, 'Violation found when non-image filename.');
 }
开发者ID:gl2748,项目名称:advertiser_entity,代码行数:15,代码来源:AdvertiserValidationTest.php


示例10: _ad_blueprint_write_css

function _ad_blueprint_write_css()
{
    // Set the location of the custom.css file
    $file_path = file_directory_path() . '/ad_blueprint/custom.css';
    // If the directory doesn't exist, create it
    file_check_directory(dirname($file_path), FILE_CREATE_DIRECTORY);
    // Generate the CSS
    $file_contents = _ad_blueprint_build_css();
    $output = '<div class="description">' . t('This CSS is generated by the settings chosen above and placed in the files directory: ' . l($file_path, $file_path) . '. The file is generated each time this page (and only this page) is loaded. <strong class="marker">Make sure to refresh your page to see the changes</strong>') . '</div>';
    file_save_data($file_contents, $file_path, FILE_EXISTS_REPLACE);
    return $output;
}
开发者ID:hoangbktech,项目名称:bhl-bits,代码行数:12,代码来源:theme-settings.php


示例11: requestTranslation

 /**
  * {@inheritdoc}
  */
 public function requestTranslation(JobInterface $job)
 {
     $name = "JobID" . $job->id() . '_' . $job->getSourceLangcode() . '_' . $job->getTargetLangcode();
     $export = \Drupal::service('plugin.manager.tmgmt_file.format')->createInstance($job->getSetting('export_format'));
     $path = $job->getSetting('scheme') . '://tmgmt_file/' . $name . '.' . $job->getSetting('export_format');
     $dirname = dirname($path);
     if (file_prepare_directory($dirname, FILE_CREATE_DIRECTORY)) {
         $file = file_save_data($export->export($job), $path);
         \Drupal::service('file.usage')->add($file, 'tmgmt_file', 'tmgmt_job', $job->id());
         $job->submitted('Exported file can be downloaded <a href="@link">here</a>.', array('@link' => file_create_url($path)));
     }
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:15,代码来源:FileTranslator.php


示例12: run

 /**
  * Called when this activity gets activated and run by the containing
  * ConductorWorkflow's controller.
  */
 public function run()
 {
     $state = $this->getState();
     $mobile = $state->getContext('sms_number');
     // Mobile Commons sends the international code in its payload. Remove it.
     $mobile = substr($mobile, -10);
     // Get user by mobile number if it exists. Otherwise create it.
     $user = dosomething_user_get_user_by_mobile($mobile);
     if (!$user) {
         $user = dosomething_user_create_user_by_mobile($mobile);
     }
     // Initialize reportback values, defaulting to create a new reportback.
     $values = array('rbid' => 0);
     // Check for a previously submitted reportback to update instead.
     if ($rbid = dosomething_reportback_exists($this->nid, $user->uid)) {
         $values['rbid'] = $rbid;
     }
     // Get the MMS URL from the provided context.
     $pictureUrl = $state->getContext($this->mmsContext);
     // Get the location for where file should be saved to.
     $fileDest = dosomething_reportback_get_file_dest(basename($pictureUrl), $this->nid, $user->uid);
     // Download and save file to that location.
     $pictureContents = file_get_contents($pictureUrl);
     $file = file_save_data($pictureContents, $fileDest);
     // Save UID and permanent status.
     $file->uid = $user->uid;
     $file->status = FILE_STATUS_PERMANENT;
     file_save($file);
     // Get the fid to submit with the report back.
     $values['fid'] = $file->fid;
     // Get answers from context and set them to their appropriate properties.
     foreach ($this->propertyToContextMap as $property => $context) {
         $values[$property] = $state->getContext($context);
     }
     // Set nid and uid.
     $values['nid'] = $this->nid;
     $values['uid'] = $user->uid;
     // Create/update a report back submission.
     $rbid = dosomething_reportback_save($values);
     // Update user's profile if this is the first completed campaign.
     $updateArgs = array();
     if (empty($_REQUEST['profile_first_completed_campaign_id']) && !empty($this->mobileCommonsCompletedCampaignId)) {
         $updateArgs['person[first_completed_campaign_id]'] = $this->mobileCommonsCompletedCampaignId;
     }
     // Opt the user out of the main campaign.
     if (!empty($this->optOutCampaignId)) {
         dosomething_sms_mobilecommons_opt_out($mobile, $this->optOutCampaignId);
     }
     // Opt user into a path to send the confirmation message.
     dosomething_sms_mobilecommons_opt_in($mobile, $this->optInPathId, $updateArgs);
     $state->setContext('ignore_no_response_error', TRUE);
     $state->markCompleted();
 }
开发者ID:sergii-tkachenko,项目名称:phoenix,代码行数:57,代码来源:ConductorActivitySmsReportBack.class.php


示例13: expand

 /**
  * {@inheritdoc}
  */
 public function expand($values)
 {
     $data = file_get_contents($values[0]);
     if (FALSE === $data) {
         throw new \Exception("Error reading file");
     }
     /* @var \Drupal\file\FileInterface $file */
     $file = file_save_data($data, 'public://' . uniqid() . '.jpg');
     if (FALSE === $file) {
         throw new \Exception("Error saving file");
     }
     $file->save();
     $return = array('target_id' => $file->id(), 'alt' => 'Behat test image', 'title' => 'Behat test image');
     return $return;
 }
开发者ID:shrimala,项目名称:DrupalDriver,代码行数:18,代码来源:ImageHandler.php


示例14: createTemporaryFile

 /**
  * Creates a temporary file, for a specific user.
  *
  * @param string $data
  *   A string containing the contents of the file.
  * @param \Drupal\user\UserInterface $user
  *   The user of the file owner.
  *
  * @return \Drupal\file\FileInterface
  *   A file object, or FALSE on error.
  */
 protected function createTemporaryFile($data, UserInterface $user = NULL)
 {
     $file = file_save_data($data, NULL, NULL);
     if ($file) {
         if ($user) {
             $file->setOwner($user);
         } else {
             $file->setOwner($this->adminUser);
         }
         // Change the file status to be temporary.
         $file->setTemporary();
         // Save the changes.
         $file->save();
     }
     return $file;
 }
开发者ID:frankcr,项目名称:sftw8,代码行数:27,代码来源:FileFieldWidgetTest.php


示例15: process

 /**
  * Parse attachments from message mimeparts.
  */
 function process(&$message, $source)
 {
     $message['attachments'] = array();
     foreach ($message['mimeparts'] as $attachment) {
         // 'unnamed_attachment' files are not really attachments, but mimeparts like HTML or Plain Text.
         // We only want to save real attachments, like images and files.
         if ($attachment->filename !== 'unnamed_attachment') {
             $destination = 'temporary://';
             $filename = mb_decode_mimeheader($attachment->filename);
             $file = file_save_data($attachment->data, $destination . $filename);
             $file->status = 0;
             drupal_write_record('file_managed', $file, 'fid');
             $message['attachments'][] = new FeedsEnclosure($file->uri, $attachment->filemime);
         }
     }
     unset($message['mimeparts']);
 }
开发者ID:tierce,项目名称:ppbe,代码行数:20,代码来源:MailhandlerCommandsFiles.class.php


示例16: process

 /**
  * Parse attachments from message mimeparts.
  */
 public function process(&$message, $source)
 {
     $message['attachments'] = array();
     foreach ($message['mimeparts'] as $attachment) {
         // 'unnamed_attachment' files are not really attachments, but mimeparts like HTML or Plain Text.
         // We only want to save real attachments, like images and files.
         if ($attachment->filename !== 'unnamed_attachment') {
             $destination = 'public://mailhandler_temp/';
             file_prepare_directory($destination, FILE_CREATE_DIRECTORY);
             $filename = mb_decode_mimeheader($attachment->filename);
             $file = file_save_data($attachment->data, $destination . $filename);
             $file->status = 0;
             drupal_write_record('file_managed', $file, 'fid');
             if (!empty($attachment->id)) {
                 $cid = trim($attachment->id, '<>');
                 $uri = 'cid:' . $cid;
                 $message['body_html'] = str_replace($uri, $file->uri, $message['body_html']);
             }
             $message['attachments'][] = new FeedsEnclosure($file->uri, $attachment->filemime);
         }
     }
     unset($message['mimeparts']);
 }
开发者ID:Sorekk,项目名称:cvillecouncilus,代码行数:26,代码来源:MailhandlerCommandsFiles.class.php


示例17: savePdfToFile

  /**
   * {@inheritdoc}
   */
  public function savePdfToFile(array $context, $destination_path_override = NULL) {
    /** @var FillPdfForm $fillpdf_form */
    $fillpdf_form = $context['form'];

    /** @var array $token_objects */
    $token_objects = $context['token_objects'];

    $destination_path = 'fillpdf';
    if (!empty($fillpdf_form->destination_path->value)) {
      $destination_path = "fillpdf/{$fillpdf_form->destination_path->value}";
    }
    if (!empty($destination_path_override)) {
      $destination_path = "fillpdf/{$destination_path_override}";
    }

    $resolved_destination_path = $this->processDestinationPath($destination_path, $token_objects, $fillpdf_form->scheme->value);
    $path_exists = file_prepare_directory($resolved_destination_path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
    $saved_file = FALSE;
    if ($path_exists === FALSE) {
      $this->logger->critical($this->t("The path %destination_path does not exist and could not be
      automatically created. Therefore, the previous submission was not saved. If
      the URL contained download=1, then the PDF was still sent to the user's browser.
      If you were redirecting them to the PDF, they were sent to the homepage instead.
      If the destination path looks wrong and you have used tokens, check that you have
      used the correct token and that it is available to FillPDF at the time of PDF
      generation.",
        ['%destination_path' => $resolved_destination_path]));
    }
    else {
      // Full steam ahead!
      $saved_file = file_save_data($context['data'], "{$resolved_destination_path}/{$context['filename']}", FILE_EXISTS_RENAME);
      $this->rememberFileContext($saved_file, $context['context']);
    }

    return $saved_file;
  }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:39,代码来源:OutputHandler.php


示例18: make_pdf

/**
 * Save page data to the specified destination as a PDF and create a database file entry.
 *
 * @param string|array $content
 *   Either of:
 *   - A string of HTML content.
 *   - A renderable array of content.
 * @param string $title
 *   Translated title for the page
 * @param $destination
 *   A string containing the destination URI. This must be a stream wrapper URI.
 *   If no value is provided, a randomized name will be generated and the file
 *   will be saved using Drupal's default files scheme, usually "public://".
 * @param $replace
 *   Replace behavior when the destination file already exists:
 *   - FILE_EXISTS_REPLACE - Replace the existing file. If a managed file with
 *       the destination name exists then its database entry will be updated. If
 *       no database entry is found then a new one will be created.
 *   - FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is
 *       unique.
 *   - FILE_EXISTS_ERROR - Do nothing and return FALSE.
 *
 * @return
 *   A file object, or FALSE on error.
 *
 * @see file_save_data()
 */
function make_pdf($content, $title, $destination = NULL, $replace = FILE_EXISTS_RENAME)
{
    require_once drupal_get_path('module', CVWOBASE_MODULE) . '/tcpdf/tcpdf.php';
    require_once drupal_get_path('module', CVWOBASE_MODULE) . '/tcpdf/config/lang/eng.php';
    if (is_string($content)) {
        $content = array('main' => array('#markup' => $content));
    }
    $pdf = new TCPDF();
    // set document information
    $pdf->SetTitle($title);
    //  $pdf->SetSubject('TCPDF Tutorial');
    //  $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
    // set default header data
    $pdf->SetHeaderData('', 0, $title, '');
    // set header and footer fonts
    $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
    $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
    // set default monospaced font
    $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
    // set margins
    $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
    $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
    //
    //set auto page breaks
    $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
    //set image scale factor
    $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    //set some language-dependent strings
    $pdf->setLanguageArray($l);
    // ---------------------------------------------------------
    // set font
    $pdf->SetFont('dejavusans', '', 10);
    // add a page
    $pdf->AddPage();
    $pdf->writeHTML(drupal_render($content));
    return file_save_data($pdf->Output('', 'S'), $destination, $replace);
}
开发者ID:zevergreenz,项目名称:Drupal,代码行数:65,代码来源:cvwobase_d7_api.php


示例19: userPictureFromLdapEntry

 /**
  * @param ldap entry array $ldap_entry
  *
  * @return drupal file object image user's thumbnail or FALSE if none present or ERROR happens.
  */
 public function userPictureFromLdapEntry($ldap_entry, $drupal_username = FALSE)
 {
     if ($ldap_entry && $this->picture_attr) {
         //Check if ldap entry has been provisioned.
         $thumb = isset($ldap_entry[$this->picture_attr][0]) ? $ldap_entry[$this->picture_attr][0] : FALSE;
         if (!$thumb) {
             return FALSE;
         }
         //Create md5 check.
         $md5thumb = md5($thumb);
         /**
          * If existing account already has picture check if it has changed if so remove old file and create the new one
          * If picture is not set but account has md5 something is wrong exit.
          */
         if ($drupal_username && ($account = user_load_by_name($drupal_username))) {
             if ($account->uid == 0 || $account->uid == 1) {
                 return FALSE;
             }
             if (isset($account->picture)) {
                 // Check if image has changed
                 if (isset($account->data['ldap_user']['init']['thumb5md']) && $md5thumb === $account->data['ldap_user']['init']['thumb5md']) {
                     //No change return same image
                     return $account->picture;
                 } else {
                     //Image is different check wether is obj/str and remove fileobject
                     if (is_object($account->picture)) {
                         file_delete($account->picture, TRUE);
                     } elseif (is_string($account->picture)) {
                         $file = file_load(intval($account->picture));
                         file_delete($file, TRUE);
                     }
                 }
             } elseif (isset($account->data['ldap_user']['init']['thumb5md'])) {
                 watchdog('ldap_server', "Some error happened during thumbnailPhoto sync");
                 return FALSE;
             }
         }
         //Create tmp file to get image format.
         $filename = uniqid();
         $fileuri = file_directory_temp() . '/' . $filename;
         $size = file_put_contents($fileuri, $thumb);
         $info = image_get_info($fileuri);
         unlink($fileuri);
         // create file object
         $file = file_save_data($thumb, 'public://' . variable_get('user_picture_path') . '/' . $filename . '.' . $info['extension']);
         $file->md5Sum = $md5thumb;
         // standard Drupal validators for user pictures
         $validators = array('file_validate_is_image' => array(), 'file_validate_image_resolution' => array(variable_get('user_picture_dimensions', '85x85')), 'file_validate_size' => array(variable_get('user_picture_file_size', '30') * 1024));
         $errors = file_validate($file, $validators);
         if (empty($errors)) {
             return $file;
         } else {
             foreach ($errors as $err => $err_val) {
                 watchdog('ldap_server', "Error storing picture: %{$err}", "%{$err_val}", WATCHDOG_ERROR);
             }
             return FALSE;
         }
     }
 }
开发者ID:tierce,项目名称:ppbe,代码行数:64,代码来源:LdapServer.class.php


示例20: createTempFiles

 /**
  * Create files for all the possible combinations of age and status.
  *
  * We are using UPDATE statements because using the API would set the
  * timestamp.
  */
 function createTempFiles()
 {
     // Temporary file that is old.
     $temp_old = file_save_data('');
     db_update('file_managed')->fields(array('status' => 0, 'changed' => REQUEST_TIME - $this->config('system.file')->get('temporary_maximum_age') - 1))->condition('fid', $temp_old->id())->execute();
     $this->assertTrue(file_exists($temp_old->getFileUri()), 'Old temp file was created correctly.');
     // Temporary file that is new.
     $temp_new = file_save_data('');
     db_update('file_managed')->fields(array('status' => 0))->condition('fid', $temp_new->id())->execute();
     $this->assertTrue(file_exists($temp_new->getFileUri()), 'New temp file was created correctly.');
     // Permanent file that is old.
     $perm_old = file_save_data('');
     db_update('file_managed')->fields(array('changed' => REQUEST_TIME - $this->config('system.file')->get('temporary_maximum_age') - 1))->condition('fid', $temp_old->id())->execute();
     $this->assertTrue(file_exists($perm_old->getFileUri()), 'Old permanent file was created correctly.');
     // Permanent file that is new.
     $perm_new = file_save_data('');
     $this->assertTrue(file_exists($perm_new->getFileUri()), 'New permanent file was created correctly.');
     return array($temp_old, $temp_new, $perm_old, $perm_new);
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:25,代码来源:UsageTest.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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