我有用PHP创建的网站.基本上它是一个发送文件类的项目.它使用Azure中的文档存储我将调用并将其发送到Azure.现在我想发送电子邮件以及存储在Google云端硬盘中.
因此应将其存储为具有公共访问权限的驱动器.我创建了以下代码.它工作正常我不希望用户输入任何内容.
$client->setAccessToken($_SESSION['accessToken']);
$service = new Google_DriveService($client);
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$file = new Google_DriveFile();
foreach ($files as $file_name) {
$file_path = 'files/'.$file_name;
$mime_type = finfo_file($finfo, $file_path);
$file->setTitle($file_name);
$file->setDescription('This is a '.$mime_type.' document');
$file->setMimeType($mime_type);
$service->files->insert(
$file,
array(
'data' => file_get_contents($file_path),
'mimeType' => $mime_type
)
);
}
finfo_close($finfo);
Run Code Online (Sandbox Code Playgroud)
我想使用cURL或使用API从Azure URL上传.邮件发送时,它会同时自动上传到驱动器.
问题更新
我有功能发送邮件这是完美的工作.我想将一个附件存储到谷歌驱动器并检索该路径到数据库的路径存储.
这一切都将基于API,无需用户交互.该文件是格式的PDF,而不是特定的字节,它根据文件的数据而不同.
问题 :
当我将文件上传到Drive原始文件名时,重命名为无标题.这是代码.
function uploadFile($credentials, $filename, $targetPath)
{
global $GAPIS;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $GAPIS . 'upload/drive/v2/files?uploadType=media');
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
//curl_setopt($ch, CURLOPT_POSTFIELDS, array("title" =>"newfile.txt"));
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($filename));
curl_setopt($ch, …Run Code Online (Sandbox Code Playgroud) 我正在开发一个确实必须扩展类WP_List_Table的插件。我已经在我的插件文件中扩展了该类(我不知道这是否是执行此操作的正确方法吗?)并包含WP_List_Table,如下所示:
if(!class_exists('WP_List_Table')){
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
Run Code Online (Sandbox Code Playgroud)
然后是扩展类的代码,然后像这样创建了我的表类的实例:
<?php
if ( ! class_exists( 'WP_List_Table' ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
Class Wp_Ban_User extends WP_List_Table
{
public function __construct()
{
add_action('admin_menu',array($this,'WBU_adminMenu'));
parent::__construct( array(
'singular'=> 'wp_list_text_link', //Singular label
'plural' => 'wp_list_test_links', //plural label, also this well be one of the table css class
'ajax' => false //We won't support Ajax for this table
) );
$this->prepare_items();
$this->display();
}
function get_columns() {
$columns = array(
'id' => 'ID',
'user_login' …Run Code Online (Sandbox Code Playgroud) 我已经开始在laravel中工作并使用Lampp。我看过许多使用虚拟主机制作用户友好的URL的教程。我想在Ubuntu 16.04上执行此操作。
以下教程对我不起作用:
https://ourcodeworld.com/articles/read/302/how-to-setup-a-virtual-host-locally-with-xampp-in-ubuntu
<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs/basicwebsite/public"
ServerName mywebsite.dev
</VirtualHost>
Run Code Online (Sandbox Code Playgroud) 我想使用 CURL 在 googledrive 根目录中创建文件夹。文件已上传到驱动器,但我需要创建一个文件夹并将文件上传到该文件夹。
根据 @hanshenrik 代码 创建文件夹正在工作 移动文件不起作用
我更新的代码:
$REDIRECT_URI = 'http' . ($_SERVER['SERVER_PORT'] == 80 ? '' : 's') . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'];
$SCOPES = array($GAPIS_AUTH . 'drive', $GAPIS_AUTH . 'drive.file', $GAPIS_AUTH . 'userinfo.email', $GAPIS_AUTH . 'userinfo.profile');
$STORE_PATH = 'credentials.json';
function uploadFile($credentials, $filename, $targetPath,$folderId)
{
global $GAPIS;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $GAPIS . 'upload/drive/v2/files?uploadType=media');
//$content = { title "mypdf.pdf", description = "mypdf.pdf", mimeType = "application/pdf" };
$contentArry = array('name' =>'veridoc', 'parents' => array('17dVe2GYpaHYFdFn1by5-TYKU1LXSAwkp'));
$contentArry …Run Code Online (Sandbox Code Playgroud)