-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload.php
More file actions
30 lines (24 loc) · 818 Bytes
/
upload.php
File metadata and controls
30 lines (24 loc) · 818 Bytes
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
<?php
header('Access-Control-Allow-Origin: *');
$TEMP_DIR = sha1_file($_FILES['model']['tmp_name']);
$UPLOADS_DIR = 'uploads/' . $TEMP_DIR . '/';
if(!is_dir($UPLOADS_DIR))
{
mkdir($UPLOADS_DIR);
}
$model_path = $UPLOADS_DIR . $_FILES['model']['name'];
move_uploaded_file($_FILES['model']["tmp_name"], $model_path);
if (empty($_FILES["texture"])) {
$texture_path = "";
} else {
$texture_path = $UPLOADS_DIR . $_FILES['texture']['name'];
move_uploaded_file($_FILES['texture']["tmp_name"], $texture_path);
}
if (empty($_FILES["normals"])) {
$normals_path = "";
} else {
$normals_path = $UPLOADS_DIR . $_FILES['normals']['name'];
move_uploaded_file($_FILES['normals']["tmp_name"], $normals_path);
}
echo json_encode(['model' => $model_path, 'texture' => $texture_path, 'normals' => $normals_path]);
?>