Php 如何使用$\u文件存储BLOB Windows Azure

Php 如何使用$\u文件存储BLOB Windows Azure,php,windows,file,azure,blob,Php,Windows,File,Azure,Blob,我正在使用windows azure blob存储服务存储数据。我的php文件是这样的 <?php require_once __DIR__ . '/vendor/autoload.php'; use WindowsAzure\Common\ServicesBuilder; use WindowsAzure\Blob\Models\CreateContainerOptions; use WindowsAzure\Blob\Models\PublicAcc

我正在使用windows azure blob存储服务存储数据。我的php文件是这样的

<?php

    require_once __DIR__ . '/vendor/autoload.php';

    use WindowsAzure\Common\ServicesBuilder;
    use WindowsAzure\Blob\Models\CreateContainerOptions;
    use WindowsAzure\Blob\Models\PublicAccessType;
    use WindowsAzure\Common\ServiceException;

    // Create blob REST proxy.
    $connectionString = "[CONNECTION STRING (WORKS)]";
    $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);


    $blob_name = "myblob";
    // Create blob REST proxy.


    try {
        //Upload blob
        $blobRestProxy->createBlockBlob("containerName",$blob_name, $_FILES['userfile']['tmp_name']);
        echo '104';
    }
    catch(ServiceException $e){
        // Handle exception based on error codes and messages.
        // Error codes and messages are here:
        // http://msdn.microsoft.com/en-us/library/windowsazure/dd179439.aspx
        $code = $e->getCode();
        $error_message = $e->getMessage();
        echo $code.": ".$error_message."<br />";
    }

?>

这个斑点创造得非常完美。。。 我遇到的唯一问题是,当我使用$_FILES['userfile']['tmp_name']时,它实际上在BLOB中存储文件的路径,而不是文件本身的内容


我的问题是,如何使用$\u FILES contents()存储BLOB?

您需要使用
file\u get\u contents()或其他方法读取文件内容:

$blob_content = file_get_contents($_FILES['userfile']['tmp_name']);
$blobRestProxy->createBlockBlob("containerName", $blob_name, $blob_content);
MS实际上试图给出一个例子,但是
fopen()
不是这样工作的