Hi, I have a file/text upload page here where I will let users create profiles
with pictures. The form writes to a TXT file and then an include command calls
the file into the page. http://www.homepokergames.com/profilesma.php - feel
free to try it and give me criticism. The problem I have now is that I want a default pic shown if no one uploads a
pic. There are 2 solutions I'm thinking of below. I don't know how to write code so i just wrote it so it would make sense to you. Does anyone know of a way for me to make this work? Even if it is some quirky solution.
SOLUTION 1
$exten=' .jpg .gif .png .bmp .JPG .JPEG .BMP';// Type of image extensions allowed
if $exten="" then $uploadfilename="default.jpg"
SOLUTION 2:
if $uploadfilename="" then change $uploadfilename to "default.jpg"
SOLUTION 3
have my Image show on the web page like <img src="default.GIF$filename">
and then give every file I upload a "default.GIF" prefix. That way if there is no file then my default file will show. But if there is a file uploaded then the name will be changed to defauilt.GIFfilename.GIF
MY CODE
<?php
$today = date("M d, Y");
$name=stripslashes($name);
$age=stripslashes($age);
$from=stripslashes($from);
$email=stripslashes($email);
$game=stripslashes($game);
$player=stripslashes($player);
$since=stripslashes($since);
$limits=stripslashes($limits);
$occupation=stripslashes($occupation);
$book=stripslashes($book);
$favsite=stripslashes($favsite);
$screenname=stripslashes($screenname);
$interests=stripslashes($interests);
$accomplishments=stripslashes($accomplishments);
$story=stripslashes($story);
// change to the directory you want files to be uploaded to
$uploaddir = "/www/k/kkiely/htdocs/profilesma/";
$uploadfilename = $FILES['userfile']['name'];
$mogrify = "/usr/local/bin/mogrify"; // Path to Imagemagick "mogrify"
$uploadfilename = ereg_replace(" ","",$uploadfilename);
$uploadfile = $uploaddir . $FILES['userfile']['name'];
$uploadfile = ereg_replace(" ","",$uploadfile);
$exten=' .jpg .gif .png .bmp .JPG .JPEG .BMP';// Type of image extensions allowed
// 1= ON, 0 = OFF
$extlimit = "yes"; //Do you want to limit the extensions of files uploaded
$limitedext = array(".gif",".jpg",".png",".jpeg",".GIF",".JPG",".JPEG",".BMP",""); //Extensions files uploaded limited to.
$ext = strrchr($uploadfilename,'.');
if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
die("<b>The file you are uploading doesn't have the correct extension so only your text was uploaded.</b><br>Click here to return to the Massachusetts profiles page<br><a href=http://www.Homepokergames.com/profilesma.php>[url]http://www.homepokergames.com/profilesma.php[/url]");
}
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
exec("$mogrify -geometry 121x122 $uploadfile");
print "<b>Your picture and text was successfully uploaded.<br>Click here to return to the Massachusetts profiles page</b><br><a href=http://www.Homepokergames.com/profilesma.php>[url]http://www.homepokergames.com/profilesma.php[/url]</a>";
} else {
print "<b>Your profile was created without an image.</b><br>Click here to return to the the Massachusetts profiles page<br><a href=http://www.Homepokergames.com/profilesma.php>[url]http://www.homepokergames.com/profilesma.php[/url]</a>";
}
print "</pre>";
$hFile = fopen( "textprofilesma.htm", "a+" );
fwrite( $hFile, "
<table width=708 cellpadding=0 cellspacing=0>
<tbody>
<tr>
<td width=14><img src=\"/tab.jpg\"></a></td>
<td width=208 align=center bgcolor=a0c0a0><font color=006000 size=3><b>$name</b></td>
<td width=14><img src=\"/tab2.jpg\"></a></td>
<td width=14><img src=\"/tab.jpg\"></a></td>
<td width=208 align=center bgcolor=a0c0a0><font color=006000><b>$from</b></td>
<td width=14><img src=\"/tab2.jpg\"></a></td>
<td width=14><img src=\"/tab.jpg\"></a></td>
<td width=208 align=center bgcolor=a0c0a0><font color=006000><b>Age: $age</b></td>
<td width=14><img src=\"/tab2.jpg\"></a></td>
</tr>
<tr bgcolor=eaeaea><td colspan=9><br></td></tr>
<tr bgcolor=eaeaea><td colspan=9>
<table width=688 align=center cellpadding=0 cellspacing=0><tbody>
<tr>
<td class=category30 valign=top width=10%><img src=\"profilesma/$uploadfilename\" align=left></a>
</td>
<td class=category30 valign=top width=30%>
<b> Name:</b> $name<br>
<b> Email/nick:</b> $email<br>
<b> Favorite Game:</b> $game<br>
<b> Favorite Player:</b> $player<br>
<b> Playing poker since:</b> $since<br>
<b> Limits:</b> $limits<br>
<b> Occupation:</b> $occupation<br>
</td>
<td class=category30 valign=top width=36%>
<b>Poker Book:</b> $book<br>
<b>Favorite PokerSite:</b> $favsite<br>
<b>Screen names:</b> $screenname<br>
<b>Interests:</b> $interests<br>
</td></tr>
<tr bgcolor=eaeaea><td class=category30 colspan=3><b>Poker Accomplishments:</b> $accomplishments</td></tr>
<tr bgcolor=eaeaea><td class=category30 colspan=3><b>Your Poker Story:</b> $story</td></tr>
</tbody></table>
</td></tr>
<tr bgcolor=eaeaea><td colspan=9><br></td></tr>
</tbody></table><br>
" );
fclose( $hFile );
$hFile2 = fopen( "textprofilesall.htm", "a+" );
fwrite( $hFile2, "$today - Massachusetts<br>
<table width=708 cellpadding=0 cellspacing=0>
<tbody>
<tr>
<td width=14><img src=\"/tab.jpg\"></a></td>
<td width=208 align=center bgcolor=a0c0a0><font color=006000 size=2><b>$name</b></td>
<td width=14><img src=\"/tab2.jpg\"></a></td>
<td width=14><img src=\"/tab.jpg\"></a></td>
<td width=208 align=center bgcolor=a0c0a0><font color=006000><b>$from</b></td>
<td width=14><img src=\"/tab2.jpg\"></a></td>
<td width=14><img src=\"/tab.jpg\"></a></td>
<td width=208 align=center bgcolor=a0c0a0><font color=006000><b>Age: $age</b></td>
<td width=14><img src=\"/tab2.jpg\"></a></td>
</tr>
<tr bgcolor=eaeaea><td colspan=9><br></td></tr>
<tr bgcolor=eaeaea><td colspan=9>
<table width=688 align=center cellpadding=0 cellspacing=0><tbody>
<tr>
<td class=category30 valign=top width=10%><img src=\"profilesma/$uploadfilename\" align=left></a>
</td>
<td class=category30 valign=top width=30%>
<b> Name:</b> $name<br>
<b> Email/nick:</b> $email<br>
<b> Favorite Game:</b> $game<br>
<b> Favorite Player:</b> $player<br>
<b> Playing poker since:</b> $since<br>
<b> Limits:</b> $limits<br>
<b> Occupation:</b> $occupation<br>
</td>
<td class=category30 valign=top width=36%>
<b>Poker Book:</b> $book<br>
<b>Favorite PokerSite:</b> $favsite<br>
<b>Screen names:</b> $screenname<br>
<b>Interests:</b> $interests<br>
</td></tr>
<tr bgcolor=eaeaea><td class=category30 colspan=3><b>Poker Accomplishments:</b> $accomplishments</td></tr>
<tr bgcolor=eaeaea><td class=category30 colspan=3><b>Your Poker Story:</b> $story</td></tr>
</tbody></table>
</td></tr>
<tr bgcolor=eaeaea><td colspan=9><br></td></tr>
</tbody></table><br>
" );
fclose( $hFile2 );
?>