forked from tohe/wmdeit_kaform
Check that uploaded file is an PDF
This commit is contained in:
parent
43fa505634
commit
24a4ffd52c
16
upload.php
16
upload.php
|
@ -14,12 +14,21 @@ foreach ($_FILES as $key=>$files){
|
||||||
for ($i=0; $i < count($files['name']); $i++){
|
for ($i=0; $i < count($files['name']); $i++){
|
||||||
$tmpname = $files['tmp_name'][$i];
|
$tmpname = $files['tmp_name'][$i];
|
||||||
|
|
||||||
|
$ft = mime_content_type($tmpname);
|
||||||
|
if ($ft != "application/pdf"){
|
||||||
|
$jo = array(
|
||||||
|
"type" => "error"
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
$jo ["file-$key-$i"] = array(
|
$jo ["file-$key-$i"] = array(
|
||||||
"url" => "url.txt",
|
"url" => "url.txt",
|
||||||
"name" => $files['name'][$i],
|
"name" => $files['name'][$i],
|
||||||
"id" => $tmpname,
|
"id" => $tmpname,
|
||||||
"size" => sprintf("%0.1fK",$files['size'][$i]/1024.0)
|
"size" => sprintf("%0.1fK",$files['size'][$i]/1024.0)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$_SESSION['files'][$tmpname]['content']=
|
$_SESSION['files'][$tmpname]['content']=
|
||||||
file_get_contents($tmpname);
|
file_get_contents($tmpname);
|
||||||
|
@ -39,8 +48,7 @@ foreach ($_SESSION['files'] as $key => $val) {
|
||||||
$j = json_encode ($jo);
|
$j = json_encode ($jo);
|
||||||
echo $j;
|
echo $j;
|
||||||
|
|
||||||
error_log("\n\n ----- files ----- \n\n$files\n\n\n");
|
#error_log("\n\n ----- files ----- \n\n$files\n\n\n");
|
||||||
$xp = xvar_dump($_FILES);
|
#$xp = xvar_dump($_FILES);
|
||||||
|
#error_log("\n\n ----- FILES ----- \n\n$$xp\n\n\n");
|
||||||
error_log("\n\n ----- FILES ----- \n\n$$xp\n\n\n");
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue