]>
Softwares of Agnibho - simpleipd.git/blob - www/attachments.php
2 require ( dirname ( __DIR__
). "/require.php" );
4 $imgs = "<div class='card mb-3 w-100'><div class='card-body'><div class='row'>" ;
5 $pdfs = "<div class='card mb-3'><div class='card-body'>" ;
6 if (! empty ( $_GET [ "pid" ])){
9 if ( in_array ( $_FILES [ "upload" ][ "type" ], [ "image/jpeg" , "image/jpg" , "image/png" , "image/gif" , "application/pdf" ])){
10 if (! empty ( $_GET [ "name" ])){
11 $name = $_GET [ "name" ]. "-" ;
16 $fname = str_replace ( "/" , "" , $pid ). "-" . $name . time (). "-" . rand ( 1000 , 9999 ). "." . pathinfo ( $_FILES [ "upload" ][ "name" ], PATHINFO_EXTENSION
);
17 move_uploaded_file ( $_FILES [ "upload" ][ "tmp_name" ], "data/attachments/" . $fname );
18 if (! empty ( $_GET [ "req" ])){
19 $db -> omitRequisition ( $_GET [ "req" ]);
23 $error = $error . "Only jpg, png, gif, pdf files are supported." ;
27 foreach ( glob ( "data/attachments/" . str_replace ( "/" , "" , $pid ). "-*" ) as $attach ){
28 if ( pathinfo ( $attach , PATHINFO_EXTENSION
)== "pdf" ){
29 $pdfs = $pdfs . "<a href='" . $attach . "'>" . pathinfo ( $attach , PATHINFO_BASENAME
). "</a>" ;
32 preg_match ( "/-([0-9]+)-/" , pathinfo ( $attach , PATHINFO_FILENAME
), $orig );
33 $imgs = $imgs . "<div class='col-md-6'><figure><a href='" . $attach . "'><img class='w-100' src='" . $attach . "'></a><figcaption>Uploaded on: " . date ( "M d, Y h:i a" , $orig [ 1 ]). "</figcaption></figure></div>" ;
37 $imgs = $imgs . "</div></div></div>" ;
38 $pdfs = $pdfs . "</div></div>" ;
44 < ?php
include ( CONFIG_LIB
. "head.php" ); ?
>
45 < title
> Attachments
</ title
>
48 < div
class = "container" >
49 < ?php
include ( CONFIG_LIB
. "top.php" ); ?
>
50 < ?php
echo getInfo ( $pid ); ?
>
51 < form
class = "mt-3 mb-3" method
= "post" enctype
= "multipart/form-data" < ?php
echo checkAccess ( "attachments" , "form" ); ?
>>
52 < label
for = "upload" > Select file to upload
. JPG
, PNG
, GIF
and PDF files are supported
. Size limit
: < span id
= "size-limit" >< ?php
echo str_replace ( "M" , "MB" , ini_get ( "upload_max_filesize" )); ?
></ span
>< span id
= "upload-error" ></ span
></ label
>
53 < input type
= "file" name
= "upload" id
= "upload" class = "form-control" >
54 < input type
= "submit" value
= "Upload" class = "mt-2 btn btn-primary" >
56 < div id
= "attachments" >
64 < ?php
include ( CONFIG_LIB
. "foot.php" ); ?
>