$content = fopen("C:\img\win.jpg", "r"); $blob_name = "win.jpg"; $blobRestProxy->createBlockBlob("pictures", $blob_name, $content);
<?php require_once "WindowsAzure/WindowsAzure.php"; require_once 'PHPUnit\autoload.php'; use WindowsAzure\Common\ServicesBuilder; use WindowsAzure\Common\ServiceException; // Create Connection String $connectionString = "DefaultEndpointsProtocol=http;AccountName=[yourAccount];AccountKey=[yourKey]"; // Create blob REST proxy. $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString); $content = fopen("C:\img\win.jpg", "r"); $blob_name = "win.jpg"; try { //Upload blob $blobRestProxy->createBlockBlob("pictures", $blob_name, $content); echo "'$blob_name' has been uploaded."; } 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 />"; } $blobRestProxy = null; ?>
<html> <head> <title>ThaiCreate.Com Tutorial</title> </head> <body> <form name="form1" method="post" action="upload2.php" enctype="multipart/form-data"> <input type="file" name="filUpload"> <input name="btnSubmit" type="submit" value="Submit"> </form> </body> </html>
<?php require_once "WindowsAzure/WindowsAzure.php"; require_once 'PHPUnit\autoload.php'; use WindowsAzure\Common\ServicesBuilder; use WindowsAzure\Common\ServiceException; // Create Connection String $connectionString = "DefaultEndpointsProtocol=http;AccountName=[yourAccount];AccountKey=[yourKey]"; // Create blob REST proxy. $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString); $content = fopen($_FILES["filUpload"]["tmp_name"], "r"); $blob_name = $_FILES["filUpload"]["name"]; try { //Upload blob $blobRestProxy->createBlockBlob("pictures", $blob_name, $content); echo "'$blob_name' has been uploaded."; } 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 />"; } $blobRestProxy = null; ?>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท