-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
84 lines (75 loc) · 2.52 KB
/
upload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require_once 'vendor/autoload.php';
require_once "./random_string.php";
use MicrosoftAzure\Storage\Blob\BlobRestProxy;
use MicrosoftAzure\Storage\Common\Exceptions\ServiceException;
use MicrosoftAzure\Storage\Blob\Models\ListBlobsOptions;
use MicrosoftAzure\Storage\Blob\Models\CreateContainerOptions;
use MicrosoftAzure\Storage\Blob\Models\PublicAccessType;
$connectionString = "DefaultEndpointsProtocol=https;AccountName=dimassubstorage;AccountKey=AgbqW1RBD7a3qmHILT3lSh9EEk3azTJE9DAkwg9m6gJsitbNqYqWX+DESpXkjjGHq2Hr1lX1i0RT+SDlZEDnUw==;";
$containerName = "blobdimas";
$blobClient = BlobRestProxy::createBlobService($connectionString);
if (isset($_POST['submit'])) {
//upload file
$fileToUpload = strtolower($_FILES["fileToUpload"]["name"]);
$content = fopen($_FILES["fileToUpload"]["tmp_name"], "r");
$blobClient->createBlockBlob($containerName, $fileToUpload, $content);
header("Location: upload.php");
}
//tampilkan list blob
$listBlobsOptions = new ListBlobsOptions();
$listBlobsOptions->setPrefix("");
$result = $blobClient->listBlobs($containerName, $listBlobsOptions);
?>
<!DOCTYPE html>
<html>
<head>
<!-- Bootstrap core CSS -->
<link href="https://getbootstrap.com/docs/4.0/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body style="padding: 20;">
<div style="background-color:grey; padding: 20;">
<a style="color:blue;" href="/index.php">Registration</a> |
<a style="color:white;" href="/upload.php">Upload</a>
</div>
<br>
<br>
<div>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="fileToUpload" accept=".jpeg,.jpg,.png" required="">
<input type="submit" name="submit" value="Upload">
</form>
</div>
<br>
<br>
<h4>Total Files : <?php echo sizeof($result->getBlobs())?></h4>
<table>
<thead>
<tr>
<th>Name</th>
<th>URL</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
do {
foreach ($result->getBlobs() as $blob)
{
?>
<tr>
<td><?php echo $blob->getName() ?></td>
<td><?php echo $blob->getUrl() ?></td>
<td><a href="vision.php?url=<?php echo $blob->getUrl()?>" class="btn btn-primary">Analize</a>
</td>
</tr>
<?php
}
$listBlobsOptions->setContinuationToken($result->getContinuationToken());
} while($result->getContinuationToken());
?>
</tbody>
</table>
</body>
</html>