xyn Posted July 31, 2006 Share Posted July 31, 2006 Hey,I have got a small problem but It's fatal.the problem is When I want images onlyto be uploaded, I ewanted to set the filetype to image/Extention.Yet when I try my way it doesn't work :/can someone help me please.-AshMy code:[code=php:0]<?phpif(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0){$fileName = $_FILES['userfile']['name'];$tmpName = $_FILES['userfile']['tmp_name'];$fileSize = $_FILES['userfile']['size'];$fileType = $_FILES['userfile']['type']; if($fileType != "image/gif" || $fileType != "image/jpg" || $fileType != "image/png" || $fileType != "image/tiff" || $fileType != "image/bmp") { die('<div align="center"> <center> <table border="1" cellspacing="0" style="border-collapse: collapse" bordercolor="#39638C" width="441" bgcolor="#AAD2FF"> <tr> <td width="100%" bgcolor="#39638C" height="10"><b> <font face="Verdana" size="1" color="#AAD2FF">Upload has failed...</font></b></td> </tr> <tr> <td width="100%"><font face="Verdana" size="1">Sorry but the file you are trying to upload is not supported by our hosting, we only host images which are:<br> - JPG<br> - GIF<br> - PNG<br> - BMP<br> - TIFF<br> If you feel the image you are uploading should be supported please contact us <a href="help.php?action=contact&method=email">here</a>.</font></td> </tr> </table> </center></div>'); }$fp = fopen($tmpName, 'r');$content = fread($fp, filesize($tmpName));$content = addslashes($content);fclose($fp);if(!get_magic_quotes_gpc()){ $fileName = addslashes($fileName);}include 'db/db.php';$date = date("d-m-y");$time = $date("g:ia");$ip = getenv('REMOTE_ADDR');$query = "INSERT INTO upload (name, size, type, content, date, time, ip ) "."VALUES ('$fileName', '$fileSize', '$fileType', '$content', '$date', '$time', '$ip')";mysql_query($query) or die('Error, query failed');echo '<div align="center"> <center> <table border="1" cellspacing="0" style="border-collapse: collapse" bordercolor="#39638C" width="441" bgcolor="#AAD2FF"> <tr> <td width="100%" bgcolor="#39638C" height="10"><b> <font face="Verdana" size="1" color="#AAD2FF">'.$fileName.' Has been uploaded...</font></b></td> </tr> <tr> <td width="100%"><font face="Verdana" size="1">Thank you for using Eumod Image hosting, Your image was uploaded successfully, you can use this image in HTML and BB Code. Please click the preferred code below:<br> </font><table border="0" cellpadding="2" style="border-collapse: collapse" bordercolor="#111111" width="100%"> <tr> <td width="20%" height="20"><b><font size="1" face="Verdana">BB Code:</font></b></td> <td width="80%" height="20"> <input type="text" name="bbcode" size="43" style="font-family: Verdana; font-size: 8pt; border: 1px solid #39638C"></td> </tr> <tr> <td width="20%" height="20"><b><font size="1" face="Verdana">HTML:</font></b></td> <td width="80%" height="20"> <input type="text" name="html" size="43" style="font-family: Verdana; font-size: 8pt; border: 1px solid #39638C"></td> </tr> </table> </td> </tr> </table> </center></div>';}else{die('<div align="center"> <center> <table border="1" cellspacing="0" style="border-collapse: collapse" bordercolor="#39638C" width="441" bgcolor="#AAD2FF"> <tr> <td width="100%" bgcolor="#39638C" height="10"><b> <font face="Verdana" size="1" color="#AAD2FF">Upload has failed...</font></b></td> </tr> <tr> <td width="100%"><font face="Verdana" size="1">Sorry but you have not added a file which you wish to be hosted by Eumod image host.</font></td> </tr> </table> </center></div>');}?>[/code] Quote Link to comment Share on other sites More sharing options...
trq Posted July 31, 2006 Share Posted July 31, 2006 How many threads on the subject are you going to open? Quote Link to comment Share on other sites More sharing options...
xyn Posted July 31, 2006 Author Share Posted July 31, 2006 :/ only this, the other was an old threat... besides that wasn't very helpful. Quote Link to comment Share on other sites More sharing options...
trq Posted July 31, 2006 Share Posted July 31, 2006 [code=php:0]if (!getimagesize($fileName)) { echo "not an image";}[/code] Quote Link to comment Share on other sites More sharing options...
xyn Posted August 1, 2006 Author Share Posted August 1, 2006 i get this error:Warning: getimagesize(pm.PNG): failed to open stream: No such file or directory in /home/eumod/public_html/upload/upload.php on line 23 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.