supermerc Posted December 25, 2006 Share Posted December 25, 2006 Hey I have this code to upload profile pictures.[code]<?session_start();$maxwidth = "250"; // Max width allowed for avatars$maxheight = "250"; // Max height allowed for avatarsif (isset($_POST['uploadit'])) {$filetype = $_FILES['userfile']['type'];$filetypex = substr($filetype,0,5);if ($filetypex == image) {$newid = "userimage/";$newid .= $_SESSION['s_username'];$newid .= ".gif";$mysock = getimagesize($_FILES['userfile']['tmp_name']);$imagewidth = $mysock[0];$imageheight = $mysock[1];if ($imagewidth <= "$maxwidth" && $imageheight <= "$maxheight") {if(!(copy($_FILES['userfile']['tmp_name'], $newid))) die("Cannot upload files.");echo "Your New Avatar Has Been Created";}else {echo "This avatar is to big, please change it";}}else {echo "This File Is Not a Image Fool";}}else {if(isset($_SESSION['s_logged_n'])){ $s_username = $_SESSION['s_username']; $session_username = $_SESSION['s_username'];$filename = 'userimage/'.$s_username.'.gif';if (file_exists($filename)) {echo '<img src="'.$filename.'" border="1">';}else {echo "You Do Not Have A Profile Picture";}?><form action="<?=$_SERVER['REQUEST_URI'] ?>" method="post" enctype="multipart/form-data">Select a file <input type="file" name="userfile" size="18"><br><input type="submit" value="Upload My Avatar" name="uploadit" size="18"><br><br><i>All Files Will Be Converted To .gif<?}else {echo 'not logged in';}}?>[/code]When my users submit a profile picture, it creates the file correctly but it doesnt show up. Its supposed to show up because of echo '<img src="'.$filename.'" border="1">'; but even if the user has a profile picture uploaded it says there is none. Quote Link to comment Share on other sites More sharing options...
mendoz Posted December 25, 2006 Share Posted December 25, 2006 can you please change the <? to <?php so I could help you better. Quote Link to comment Share on other sites More sharing options...
supermerc Posted December 25, 2006 Author Share Posted December 25, 2006 Sure here you go[code]<?phpsession_start();$maxwidth = "250"; // Max width allowed for avatars$maxheight = "250"; // Max height allowed for avatarsif (isset($_POST['uploadit'])) {$filetype = $_FILES['userfile']['type'];$filetypex = substr($filetype,0,5);if ($filetypex == image) {$newid = "userimage/";$newid .= $_SESSION['s_username'];$newid .= ".gif";$mysock = getimagesize($_FILES['userfile']['tmp_name']);$imagewidth = $mysock[0];$imageheight = $mysock[1];if ($imagewidth <= "$maxwidth" && $imageheight <= "$maxheight") {if(!(copy($_FILES['userfile']['tmp_name'], $newid))) die("Cannot upload files.");echo "Your New Avatar Has Been Created";}else {echo "This avatar is to big, please change it";}}else {echo "This File Is Not a Image Fool";}}else {if(isset($_SESSION['s_logged_n'])){ $session_username = $_SESSION['s_username'];$filename = 'userimage/'.$s_username.'.gif';if (file_exists($filename)) {echo '<img src="'.$filename.'" border="1">';}else {echo "You Do Not Have An Avatar";}?><form action="<?=$_SERVER['REQUEST_URI'] ?>" method="post" enctype="multipart/form-data">Select a file <input type="file" name="userfile" size="18"><br><input type="submit" value="Upload My Avatar" name="uploadit" size="18"><br><br><i>All Files Will Be Converted To .gif<?php}else {echo 'not logged in';}}?>[/code] Quote Link to comment Share on other sites More sharing options...
supermerc Posted December 25, 2006 Author Share Posted December 25, 2006 bump Quote Link to comment Share on other sites More sharing options...
supermerc Posted December 26, 2006 Author Share Posted December 26, 2006 bump Quote Link to comment Share on other sites More sharing options...
emehrkay Posted December 26, 2006 Share Posted December 26, 2006 [quote author=mendoz link=topic=119885.msg491358#msg491358 date=1167070486]can you please change the <? to <?php so I could help you better.[/quote]what does that matter? Quote Link to comment Share on other sites More sharing options...
supermerc Posted December 26, 2006 Author Share Posted December 26, 2006 <? doesnt work on some server, no on can help me though? Quote Link to comment Share on other sites More sharing options...
btherl Posted December 26, 2006 Share Posted December 26, 2006 emehrkay, it matters because of syntax highlighting on the forum.Supermerc, try adding some debugging output to your script, such as printing out the filename you are testing for existence. Also, if you have direct access to your files (through ftp or a web interface), take a look to see if the file is really there.In particular I would use:[code=php:0]echo "You Do Not Have An Avatar (looked for $filename)";[/code] Quote Link to comment Share on other sites More sharing options...
supermerc Posted December 26, 2006 Author Share Posted December 26, 2006 I dont undestand what you mean Quote Link to comment Share on other sites More sharing options...
supermerc Posted December 26, 2006 Author Share Posted December 26, 2006 Fixed it myself Quote Link to comment Share on other sites More sharing options...
mendoz Posted December 26, 2006 Share Posted December 26, 2006 all by yourself?! ;) Quote Link to comment Share on other sites More sharing options...
supermerc Posted December 26, 2006 Author Share Posted December 26, 2006 And some help from mendoz Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.