There is a photo upload code. It loads the client's photo into the database. But the problem is that it can only upload one photo. If you upload a second photo, it simply replaces it by removing the old photo.
Photo upload form display code
<div class="col-md-2" style="width: 223px; float: right; margin-top: -210px;">
<div class="x_panel">
<span class="input-text" style="margin-right: 5px;">Include Photo (+)</span>
<input contenteditable="true" onchange="saveUpdate('medsoft','Inst_Int','photos','<?=$row['Int_Int'];?>',this.value);" style="margin-left: 5px;width: 30px" type="1checkbox" class="1js-switch" name="photo" value="<?= $row['photos'];?>"><? //= ($row['photos']=='+' ? 'checked' : null);?>
<div class="x_contenti">
<br><br>
<span class="input-text " >Photo</span>
<!-- <a style="height: 26px; margin-left: 10px;" href="###/kont.php?action=new_kod&rowkod=<?//=$row['Sch_Row']?>" class="jsdelete btn btn-warning btn-sm" data-alert="Add photo ? ">Add</a> -->
<br><br>
<a style="cursor:pointer;border:1px solid;padding:3px;background: #eee; float: right; margin-top: -35px;" data-ch="<?=$row['Count_Row']?>" data-toggle="modal" data-target="#myModal">
Upload a photo
</a>
<!--
<a style="cursor:pointer;border:1px solid;padding:2px;background: red;color:#fff;" href="/medsoft.php?action=del_foto&rowfoto=<?//=$row['Sn_Row']?>" class="jsdelete btn btn-warning btn-sm" data-alert="Delete photo ?">Delete photo</a>
-->
<?php
if ($row['Photo_dev']=='+') {
?>
<div style="border: 0px solid; ">
<img id="ch-pers-img<?=$row['Ch_Rs']?>" src="/images/<?=$row['Chs_Rs']?>.jpg?t=<?=time ()?>" width="189">
</div>
<?php
}
?>
</div>
</div>
</div>
Photo Upload Processing Code
<div class="modal fade " id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Photo Upload</h4>
</div>
<div class="modal body">
<div>
<form action="upplo.php" method="post" name="uplod" id="uplod" enctype="multipart/form-data">
<input type="file" name="filename"><br>
<br>
<input id="submit-card" type="button" form="uplod" value="Upload">
</form>
</div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
Photo upload code
<?php
mysql_set_charset('utf8',$db);
if($_FILES["filename"]["size"] > 2024*3*2024) {
echo ("File size exceeds three megabytes");
exit;
}
$success=[];
$errors=[];
foreach( $_FILES as $file ){
// Check if the file is loaded
if(is_uploaded_file($file["tmp_name"])) {
// If the file is uploaded successfully, move it
// from temporary directory to destination
if (move_uploaded_file($file["tmp_name"], "images/".intval($_GET['ch']).".jpg"))
$success[]=intval($_GET['ch']).".jpg"."?t=".time();
// $db = mysql_connect("localhost","armit_mit","oZ5hI7jID");
// mysql_select_db("armit_mit",$db);
$result_foto = mysql_query ("UPDATE `Persons` SET `Photos` = '+' where `Ch-Persons` = ".intval($_GET['ch'])."", $db);
} else {
$errors[] = "Error loading file ".intval($_GET['ch']).".jpg";
}
}
echo json_encode(['success'=>$success,'errors'=>$errors]);
?>
What needs to be done so that you can upload several photos at once.
The code also contains a code for displaying a photo, which is displayed when the + sign is specified in the database in the "fhotos" line.