mattm1712 Posted April 6, 2011 Share Posted April 6, 2011 hi i have wrote this code for uploading an image this is my main code <?php $lastimage2 = mysql_query("SELECT * FROM images WHERE id=$view"); $li2 = mysql_fetch_assoc($lastimage2); if ($page=="P8"&$view>0) { echo "<table class=roung bgcolor='#000000'><tr><TD><img src=uploaded/$li2[picname] width='760' height='540'></td></tr></table>"; include 'picclicks.php'; echo "<tr><td>Views: $clicks2 </td></tr>"; } else { if ($_SESSION['user']) { If ($imagereport='1') { } echo" <table bgcolor='#000000' class=round><tr><td class=ach> <form action='index.php?variable=".$page."&fun=upload' method='POST' enctype='multipart/form-dat'> <input type='file' name='myfile'> <input type='submit' value='Upload'> </td></tr></table></form> "; } else { echo "Please Login to upload new photos!"; } ?> then i have this for imageupload.php <?php if ($_FILES) { $username = $_SESSION['user']; $date =time(); $name = $_FILES["myfile"]["name"]; $type = $_FILES["myfile"]["type"]; $size = $_FILES["myfile"]["size"]; $temp = $_FILES["myfile"]["tmp_name"]; $error = $_FILES["myfile"]["error"]; $hs=$_POST['High Score']; $g=$_POST['Glitch']; $f=$_POST['Funny']; $o=$_POST['Other']; $tags = new Array(); foreach($_POST['tag'] as $tag){ if($tag){ tags[] = $tag; } } $tag = implode(',',$tags); if ($error > 0 ) die("Error uploading file! Code $error."); else { if ($type =="image/jpeg") { include 'connect.inc'; move_uploaded_file($temp,"uploaded/".$name); mysql_query("INSERT INTO images VALUES('','$name','','$username','$date','0','0','0','0','0','0','0','0')"); $uploadreport='1'; } else { } } } else { } ?> my database is set right, and this is what i have in my index file if ($fun=="upload") { include 'imageupload.php'; } when i click upload it directs it to index.php?variable=P8&fun=upload but nothing shows up on screen if u need more details plz ask cheers matt Link to comment https://forums.phpfreaks.com/topic/232896-image-upload-problemplz-help/ Share on other sites More sharing options...
3raser Posted April 6, 2011 Share Posted April 6, 2011 A bit confused on what your asking, hope this helps. Mind putting it in [*PHP] tags to make it easier to read? if ($page=="P8"&$view>0) Shouldn't that be this: if ($page=="P8" && $view>0) Also, to display the image, wouldn't you need to call it via header? header("Content-type:image/jpeg"); <?php if ($_FILES) { $username = $_SESSION['user']; $date =time(); $name = $_FILES["myfile"]["name"]; $type = $_FILES["myfile"]["type"]; $size = $_FILES["myfile"]["size"]; $temp = $_FILES["myfile"]["tmp_name"]; $error = $_FILES["myfile"]["error"]; $hs=$_POST['High Score']; $g=$_POST['Glitch']; $f=$_POST['Funny']; $o=$_POST['Other']; $tags = new Array(); foreach($_POST['tag'] as $tag){ if($tag){ tags[] = $tag; } } $tag = implode(',',$tags); if ($error > 0 ) die("Error uploading file! Code $error."); else { if ($type =="image/jpeg") { include 'connect.inc'; move_uploaded_file($temp,"uploaded/".$name); mysql_query("INSERT INTO images VALUES('','$name','','$username','$date','0','0','0','0','0','0','0','0')"); $uploadreport='1'; header("Content-type:image/jpeg"); } else { } } } else { } ?> Link to comment https://forums.phpfreaks.com/topic/232896-image-upload-problemplz-help/#findComment-1197817 Share on other sites More sharing options...
spiderwell Posted April 6, 2011 Share Posted April 6, 2011 you arent getting the include file as you havent filled variable $fun with a $_GET['fun'] request, so it will never meet the comparison if($fun=="upload") Link to comment https://forums.phpfreaks.com/topic/232896-image-upload-problemplz-help/#findComment-1197820 Share on other sites More sharing options...
3raser Posted April 6, 2011 Share Posted April 6, 2011 Also: echo "<table class=roung bgcolor='#000000'><tr><TD><img src='uploaded/". $li2[picname] ."' width='760' height='540'></td></tr></table>"; Use that instead of echo "<table class=roung bgcolor='#000000'><tr><TD><img src=uploaded/$li2[picname] width='760' height='540'></td></tr></table>"; Link to comment https://forums.phpfreaks.com/topic/232896-image-upload-problemplz-help/#findComment-1197822 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.