-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck1.php
62 lines (58 loc) · 1.75 KB
/
check1.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
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$char = '.';
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
}
$question = $_POST['number'];
$expensions= array("txt");
$_POST['question'] = 4;
if(in_array($file_ext,$expensions)=== false){
$errors[]="extension not allowed, please choose a JPEG or PNG file.";
}
if($file_size > 102097152){
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"uploads/".$file_name);
echo "Success";
echo $file_name;
echo $question;
$input = 'out'.$question.'.txt';
echo $input;
$ah = fopen("uploads/$file_name", 'rb');
$bh = fopen("1/$input", 'rb')or die(header('location:sorry.php'));
if(!$bh)
{
header('location:sorry.php');
}
$result = true;
while(!feof($ah))
{
if(fread($ah, 8192) != fread($bh, 8192))
{
$result = false;
break;
}
}
fclose($ah);
fclose($bh);
if($result == true)
{
print 'They are same';
$_POST['correct'] = 1;
header('location:success.php');
}
else {
print 'not same';
$_POST['correct'] = 0;
header('location:failure.php');
}
}else{
print_r($errors);
}
?>