Welcome to WebmasterWorld Guest from 184.73.18.109

Forum Moderators: coopster & jatar k

Help with foreach

   
3:37 pm on Jan 13, 2010 (gmt 0)

5+ Year Member



I have an image upload script that a programmer wrote for me. It uploads 3 images and then echos them out:

<?
foreach($_SESSION['mupload_files'] as $file){
?>
<img width="150" src="uploaded_images/<?=$file['newname']?>" /><br /><br />
<?
}
$_SESSION['mupload_files']=array();
?>

How can I echo just one image on it's own, outside of the loop.

I.e.

echo "$image2;"

3:47 pm on Jan 13, 2010 (gmt 0)

5+ Year Member



Here are som other parts of the code which may or may not be relevant.


function fileExtension($filename,$lower=true)
{
$f=explode('.',$filename);
$n=count($f)-1;
if($lower) return strtolower($f[$n]);
else return $f[$n];
}

$i=1;
foreach($_SESSION['mupload_files'] as $x=>$file){
$file['newname']=$i.'_'.date('Y-m-d_H-i-s').'.'.fileExtension($file['name']);
rename($file['tmp_name'],'uploaded_images/'.$file['newname']);
$_SESSION['mupload_files'][$x]=$file;
$i++;
}


window.mfiles.addUploader("fileselect.png",60,20,
"files_selector","files_t",
"mupload.php",{"session_id":"<?=session_id();?>"},
10240,"*.png; *.jpg; *.gif; *.bmp","Image Files",100,3);
window.mfiles.addUploader("fileselect.png",60,20,
"files_selector2","files2_t",
"mupload.php",{"session_id":"<?=session_id();?>"},
10240,"*.png; *.jpg; *.gif; *.bmp","Image Files",100,3);
window.mfiles.addUploader("fileselect.png",60,20,
"files_selector3","files3_t",
"mupload.php",{"session_id":"<?=session_id();?>"},
10240,"*.png; *.jpg; *.gif; *.bmp","Image Files",100,3);
 

Featured Threads

Hot Threads This Week

Hot Threads This Month