rarebit Posted May 17, 2008 Share Posted May 17, 2008 I have a directory where users can upload an image, this is given their username. When used, it is checked to see if it exists: $img = "<img src='"._SEP.$site_data['dir_path'].$file_dir.$uname.".gif' alt='VOID'>"; if (!file_exists($file_dir.$uname.".gif")) { $img = "No Image"; } However, if there is no username then an image is shown anyway, there is no image name '.gif' in the folder, even though it shows another image from somewhere else. Is this a peculiarity of 'file_exists()' (maybe using stat), or what. If before all of this I put: if(strcmp($uname, "")==0) { $uname = "VOID"; } then it works as expected... This just seems to be an extra unwanted step! Sorry about this post, sort of solved it as it was written... Link to comment https://forums.phpfreaks.com/topic/106077-bemused/ Share on other sites More sharing options...
nloding Posted May 17, 2008 Share Posted May 17, 2008 Should you be checking to see if $site_data['dir_path'].$file_dir.$uname.".gif" exists, not just $file_dir.$uname.".gif" ?? Depending on where you're at in your directory structure, that'd be your problem. Link to comment https://forums.phpfreaks.com/topic/106077-bemused/#findComment-543682 Share on other sites More sharing options...
rarebit Posted May 17, 2008 Author Share Posted May 17, 2008 No, because i'm using mod_rewrite with includes etc, and the actual src path needs to be different. But either way they still wouldn't exist... Link to comment https://forums.phpfreaks.com/topic/106077-bemused/#findComment-543689 Share on other sites More sharing options...
rarebit Posted May 17, 2008 Author Share Posted May 17, 2008 this should work better in this instance: $img = "No Image"; if(isset($uname)) { $img = "<img src='"._SEP.$site_data['dir_path'].$file_dir.$uname.".gif' alt='VOID'>"; } Link to comment https://forums.phpfreaks.com/topic/106077-bemused/#findComment-543697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.