-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.php
More file actions
executable file
·37 lines (35 loc) · 992 Bytes
/
function.php
File metadata and controls
executable file
·37 lines (35 loc) · 992 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
31
32
33
34
35
36
37
<?php
session_start();
/**
* function who check if the file in parameter is in on format jpg, gif, or mp4
* @param $way
* @return True or false
*/
function checkFormat($way) {
$keyWord = preg_split("/[\\\\,.\/]+/ ", $way);
$formatAccept = ["gif"];
for ($j = 0; $j <= sizeof($formatAccept); $j++) {
if ($keyWord[sizeof($keyWord) - 1] === $formatAccept[$j]) {
return true;
}
}
return false;
}
function copyToJpg($src)
{
$dest = "./asset/img/jpg/".$_POST['title']."_".$_SESSION['user']['id'].".jpg";
copy($src, $dest);
}
/**
* function who save one file un directories user/file
* @param $file
* @return int;
*/
function saveFile() {
$move = move_uploaded_file($_FILES['file']['tmp_name'], "./asset/img/gif/".$_POST['title']."_".$_SESSION['user']['id'].".gif");
if ($move === false) {
return -1;
} else
copyToJpg("./asset/img/gif/".$_POST['title']."_".$_SESSION['user']['id'].".gif");
return 0;
}