added filetype to json response of duplicates

This commit is contained in:
Chris
2018-12-26 13:29:24 +01:00
parent b6609b1df2
commit 66fc8aff14
3 changed files with 13 additions and 10 deletions

View File

@@ -33,14 +33,16 @@ if($_REQUEST['base64'])
base64ToFile($data, $tmpfile);
//get the file type
$type = getTypeOfFile($tmpfile);
//check for duplicates
$sha1 = sha1_file($tmpfile);
$ehash = sha1Exists($sha1);
if($ehash && file_exists(ROOT.DS.'data'.DS.$ehash.DS.$ehash))
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'url'=>URL.$ehash)));
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'filetype'=>$type,'url'=>URL.$ehash)));
//get the file type
$type = getTypeOfFile($tmpfile);
//cross check filetype for controllers
//

View File

@@ -35,13 +35,15 @@ $name = basename($url);
$tmpfile = ROOT.DS.'tmp'.DS.$name;
file_put_contents($tmpfile,file_get_contents($url));
$type = getTypeOfFile($tmpfile);
//check for duplicates
$sha1 = sha1_file($tmpfile);
$ehash = sha1Exists($sha1);
if($ehash && file_exists(ROOT.DS.'data'.DS.$ehash.DS.$ehash))
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'url'=>URL.$ehash)));
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'filetype'=>$type,'url'=>URL.$ehash)));
$type = getTypeOfFile($tmpfile);
//cross check filetype for controllers
//

View File

@@ -26,15 +26,14 @@ $hash = sanatizeString(trim($_REQUEST['hash']))?sanatizeString(trim($_REQUEST['h
// check for POST upload
if ($_FILES['file']["error"] == UPLOAD_ERR_OK)
{
//get the file type
$type = getTypeOfFile($_FILES['file']["tmp_name"]);
//check for duplicates
$sha1 = sha1_file($_FILES['file']["tmp_name"]);
$ehash = sha1Exists($sha1);
if($ehash && file_exists(ROOT.DS.'data'.DS.$ehash.DS.$ehash))
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'url'=>URL.$ehash)));
//get the file type
$type = getTypeOfFile($_FILES['file']["tmp_name"]);
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'filetype'=>$type,'url'=>URL.$ehash)));
//cross check filetype for controllers
//