basically, user uploads image. image taken, checked right file type , uploaded server here:
$directory = 'uploads/'; $files = glob($directory . 'audit'.$id.'_image*.jpg'); $count = 0; if ($files !== false) { $count = count($files) + 1; } if (!empty($_files)) { $tempfile = $_files['file']['tmp_name']; //3 $rename = explode('.', $_files['file']['name']); $namestring = 'audit'.$id.'_image'.$count.'.'.strtolower($rename[1]); //only allow image files $allowed = array( 'jpg' ); if (in_array(strtolower($rename[1]), $allowed)) { $targetpath = dirname( __file__ ) . $ds. $storefolder . $ds; //4 $targetfile = $targetpath. $namestring; //5 move_uploaded_file($tempfile,$targetfile); //6 } } the name of file changed suit format retrieval. audit(id)_image*.jpg
or example audit65_image1.jpg
now, works fine, , image uploaded.
however, when comes retrieval viewing file.. happens !
$directory = 'uploads/'; $files = glob($directory . 'audit'.$row['id'].'_image*.jpg'); if (count($files) > 0) { ?> <div class="row"> <div class="col-md-12"> <section class="panel"> <div class="panel-body"> <div class="col-md-12" style="text-align:center;"> <div class="panel-heading no-b"> <h5>image <b>uploads</b></h5> </div> </div> <?php foreach ($files $key => $value) { ?> <div class="col-sm-2"> <a href=<?php echo '"'.$value.'"'; ?>><img style="box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.65);" src=<?php echo '"'.$value.'"'; ?> class="superbox-img"/></a> </div> <?php } ?> </div> </section> </div> </div> <?php } ?> which again, can't see problem with! however, on webpage.. load incorrect image, if uploaded 3 files, it's asif they're saved system or part of system somewhere , it's causing big issue. it's showing image doesn't exist. if change file name audit65_image1.jpg audit65_image3.jpg image shown on webpage changes. i'm utterly confused. tried loading webpage on different computer account caching , loaded wrong image on there though file not exist image it's loading!
does have idea what's going wrong?
to give unique name image files try add timestamp name of image before saving.
Comments
Post a Comment