-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.php
More file actions
61 lines (58 loc) · 1.64 KB
/
Copy pathgenerate.php
File metadata and controls
61 lines (58 loc) · 1.64 KB
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
<?php
session_start();
$pageTitle = 'Card';
require_once "inc/template/header.php";
if(isset($_POST['submit']))
{
// Extraction
$num=$_POST['num'];
$image=$_FILES['img'];
// img data
$imageName=$image['name'];
$imageTmpName=$image['tmp_name'];
$imageError=$image['error'];
$imageSize=$image['size'];
$imageSizeMB=$imageSize/(1024**2);
$ext=pathinfo($imageName,PATHINFO_EXTENSION);
$errors=[];
// validation
if(empty($num))
{$errors[]="num is required";}
elseif (!is_numeric($num)) {$errors[]="num is not valid";}
if($imageError>0)
{$errors[]="error while uploading";}
else if(!in_array(strtolower($ext),['jpg','png','jpeg','gif'])){$errors[]="must be image";}
else if($imageSizeMB>1) {$errors[]="image maxsize must be 1mb";}
if(empty($errors))
{
// upload img
move_uploaded_file($imageTmpName,"uploads/$imageName");
?>
<div class="container someIdits" id = "htmlContent">
<?php
//loop
for($i=0;$i<$num;$i++)
{
if($i % 2 == 0){
?>
<img class="mt-2 float-right" src="uploads/<?php echo $imageName ?>">
<div class="clr"></div>
<?php
}else{
?>
<img class="mt-2" src="uploads/<?php echo $imageName ?>">
<?php }
echo "<br>";
}
?>
</div>
<a class="btn btn-info forPositon" id="download">Download</a>
<?php
}
else{
$_SESSION['errors']=$errors;
header("location:index.php");
}
}
require_once "inc/template/footer.php";
?>