homepage Welcome to WebmasterWorld Guest from 54.167.11.16
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Help with foreach
scraptoft




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

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;"

 

scraptoft




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

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);

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved