小编Tox*_*xid的帖子

PHP - 上传多个文件

我正在开发一个wordpress插件,我希望能够从表单上传多张图片.现在,当我有两张图片的表单并将其提交为空时,我的$ _FILES数组如下所示:

Array (
    [image] => Array ( 
        [name] => Array ( 
            [1] => 
            [2] =>
        ) 
        [type] => Array ( 
            [1] => 
            [2] =>
        ) 
        [tmp_name] => Array ( 
            [1] => 
            [2] =>
        ) 
        [error] => Array ( 
            [1] => 4 
            [2] => 4
        ) 
        [size] => Array ( 
            [1] => 0 
            [2] => 0 
        ) 
    ) 
)
Run Code Online (Sandbox Code Playgroud)

现在的问题是我想使用wordpress'上传处理程序,wp_handle_upload.它期望$ _FILES数组作为参数,但只有一个文件.我想它只能是两个阵列深,而不是我的三个阵列.所以我想知道是否有办法从$ _FILES数组中一次提交一个文件.每个数组中的文件具有相同的密钥.

编辑:改变了帖子,因为我了解到wp_handle_upload想要$ _FILES数组作为参数.

php forms wordpress upload plugins

5
推荐指数
1
解决办法
6192
查看次数

Drupal 7 - 以编程方式创建节点,添加嵌入到字段的youtube

我正在尝试以编程方式创建节点.使用带有youtube扩展程序的媒体模块,我想用youtube数据填充一个字段.从我到目前为止所读到的内容来看,它看起来像这样:

   <?php
    // $value in this case is the youtube ID.
    $file = new stdClass();
      $file->uid = 1;
      $file->filename = $value;
      $file->uri = 'youtube://v/' . $value;
      $file->filemime =  'video/youtube';
      $file->type = 'video';
      $file->status = 1;
      $youtube = file_save($file);

    node->field_youtube[$node->language]['0']['fid'] = (array) $youtube->fid;
    ?>
Run Code Online (Sandbox Code Playgroud)

我通过查看bartik主题中$ content变量中的信息来了解这一点.但是,这会导致"错误的文件扩展名"错误.我也尝试将整个url放在$ file-> uri中并使用file_get_mimetype,然后它没有抛出错误但是视频也没有用.有谁知道如何做到这一点?

php drupal-7

4
推荐指数
1
解决办法
2587
查看次数

Drupal数据库API查询 - 如果存在则为row.update,否则为row.insert

我一直在尝试在drupal中运行一个查询,如果它们已经存在则会更新条目,如果没有,则插入一个新条目.代码现在看起来像这样:

db_query("IF EXISTS (SELECT %d FROM {uc_posten_packages.pid})
UPDATE {uc_posten_packages} SET title = '%s', label = '%s', cost = '%d', length = '%d', width ='%d', height = '%d', weight = '%d'  WHERE pid = %d
ELSE
INSERT INTO {uc_posten_packages} VALUES ('%d', '%s', '%s', '%d', '%d', '%d', '%d', '%d')",$id, $title, $label, $rate, $length, $width, $height, $weight, $id, $id, $title, $label, $rate, $length, $width, $height, $weight);
Run Code Online (Sandbox Code Playgroud)

我不明白为什么该查询会引发错误.错误中的所有数字都是正确的

...near 'IF EXISTS (SELECT 1 FROM uc_posten_packages.pid) UPDATE uc_posten_packages ' at line 1 query:
IF EXISTS …
Run Code Online (Sandbox Code Playgroud)

mysql drupal upsert

3
推荐指数
1
解决办法
8672
查看次数

Drupal - 将'user /%/ edit/uprofile'设置为'user /%/ edit'上的默认选项卡

我正在使用内容配置文件模块.当用户在他们的查看个人资料页面上并按下编辑时,他们希望显示个人资料编辑页面,而不是现在的帐户设置.内容配置文件编辑页面的路径是"user /%/ edit/uprofile".有谁知道如何将'user /%/ edit/uprofile'设置为'user /%/ edit'的默认选项卡?

php drupal menu

2
推荐指数
1
解决办法
4690
查看次数

标签 统计

php ×3

drupal ×2

drupal-7 ×1

forms ×1

menu ×1

mysql ×1

plugins ×1

upload ×1

upsert ×1

wordpress ×1