Advertisement
Mujiburrohman

upload_azure

Jul 4th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.73 KB | None | 0 0
  1. <?php
  2. require_once 'vendor/autoload.php';
  3. require_once "./random_string.php";
  4. use MicrosoftAzure\Storage\Blob\BlobRestProxy;
  5. use MicrosoftAzure\Storage\Common\Exceptions\ServiceException;
  6. use MicrosoftAzure\Storage\Blob\Models\ListBlobsOptions;
  7. use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions;
  8. use MicrosoftAzure\Storage\Blob\Models\PublicAccessType;
  9. $connectionString = "DefaultEndpointsProtocol=https;AccountName=strgcikupapp;AccountKey=tbixwRohFQj+wPMFK9sHeJpNyy47Yn68V0o1+VWZjR9MonR0iZURA4fqFYxT05Jjt3SVJ3UIJmFUfL9+YsKXhQ==;EndpointSuffix=core.windows.net";
  10. $blobClient = BlobRestProxy::createBlobService($connectionString);
  11. $containerName = "cikupqueue";
  12.    
  13. if (isset($_POST['submit'])) {
  14.     $fileToUpload = $_FILES["fileToUpload"]["name"];
  15.     $content = fopen($_FILES["fileToUpload"]["tmp_name"], "r");
  16.     echo fread($content, filesize($fileToUpload));
  17.        
  18.     $blobClient->createBlockBlob($containerName, $fileToUpload, $content);
  19.     header("Location: upload_img.php");
  20. }  
  21.    
  22. $listBlobsOptions = new ListBlobsOptions();
  23. $listBlobsOptions->setPrefix("");
  24. $result = $blobClient->listBlobs($containerName, $listBlobsOptions);
  25. ?>
  26.  
  27. <!DOCTYPE html>
  28. <html>
  29.     <head>
  30.         <meta charset="utf-8">
  31.         <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  32.         <meta name="description" content="">
  33.         <meta name="author" content="">
  34.         <title>Analyze With Upload Photo</title>
  35.         <link rel="canonical" href="https://getbootstrap.com/docs/4.0/examples/starter-template/">
  36.         <!-- Bootstrap core CSS -->
  37.         <link href="https://getbootstrap.com/docs/4.0/dist/css/bootstrap.min.css" rel="stylesheet">
  38.         <!-- Custom styles for this template -->
  39.         <link href="starter-template.css" rel="stylesheet">
  40.          <style>
  41.        th {
  42.     background-color:#1e90ff; border-right:solid 2px black; border-bottom:solid 2px black; font-size:8pt ; padding:5px;font-family: arial;border-top: solid 2px black;border-left: solid 2px black;
  43.     }
  44.     td{
  45.         border-right:solid 2px black; border-bottom:solid 2px black; font-size:8pt ; padding:5px;font-family: arial;border-left: solid 2px black;border-top: solid 2px black; text-align: right;  
  46.     }
  47. </style>
  48.     </head>
  49.    
  50.     <body>
  51.  
  52.                     <form action="upload_img.php" method="post" enctype="multipart/form-data">
  53.                         <input type="file" name="fileToUpload" accept=".jpeg,.jpg,.png" required="">
  54.                         <input type="submit" name="submit" value="Upload">
  55.                     </form>
  56.            
  57.                 <br>
  58.             <table>
  59.             <tr>
  60.                 <th>Nama File</th>
  61.                 <th>URL Gambar</th>
  62.                 <th>Action</th>
  63.             </tr>
  64.        
  65.             <tbody>
  66.                         <?php
  67.                         do {
  68.                             foreach ($result->getBlobs() as $blob) {
  69.                         ?>                     
  70.                         <tr>
  71.                             <td><?php echo $blob->getName() ?></td>
  72.                             <td><?php echo $blob->getUrl() ?></td>
  73.                             <td>
  74.                                 <form action="img_vision.php" method="post">
  75.                                     <input type="hidden" name="url" value="<?php echo $blob->getUrl()?>">                      
  76.                                     <input type="submit" name="submit"  value="Lihat">
  77.                                 </form>
  78.                             </td>
  79.                         </tr>
  80.                         <?php
  81.                             } $listBlobsOptions->setContinuationToken($result->getContinuationToken());
  82.                         } while($result->getContinuationToken());
  83.                         ?>
  84.                     </tbody>   
  85.                 </table>
  86.                 </div>
  87.            
  88.             <!-- Placed at the end of the document so the pages load faster -->
  89.             <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  90.             <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery-slim.min.js"><\/script>')</script>
  91.             <script src="https://getbootstrap.com/docs/4.0/assets/js/vendor/popper.min.js"></script>
  92.             <script src="https://getbootstrap.com/docs/4.0/dist/js/bootstrap.min.js"></script>
  93.            
  94.             </body>
  95.         </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement