i tried atli's manual and the picture is not appearing?
Collapse
X
-
yeah.. in atli's code there were files in the DB but when i tried to check my own, there was no files.. im going to start again.. hope i can do it.. i'll try to fix the codes.. the insert query maybe has an error..
here's now my code:
Code:<?php error_reporting (E_ALL ^ E_NOTICE); $pid = base64_decode($_GET['id']); if(isset($_FILES['uploaded_file'])) { if($_FILES['uploaded_file']['error'] == 0) {$Link = mysqli_connect("localhost","root","tupi", "amyak_maleh"); if(mysqli_connect_errno()){ die("Mysql connection failed:".mysqli_connect_errno()); } $name = mysqli_real_escape_string($Link, $_FILES['uploaded_file']['name']); $data = mysqli_real_escape_string($Link, file_get_contents($_FILES ['uploaded_file']['tmp_name'])); $query = "INSERT INTO pix(pid, title, imgdata) values('$pid', '$name', '$data')"; $result = mysqli_query($Link, $query); if($result) { $asd = "Succes! YOur file was successfully added!"; $alert = base64_encode($asd); header("Location:registration.php?alert=$alert"); exit(); } else { $asd = "Error! An error occurred while the file was being uploaded. Error code:".$_FILES['uploaded_file']['error']; $alert = base64_encode($asd); header("Location:picul.php?alert=$alert"); exit(); } mysqli_close($Link); }
Comment
-
yeah.. in atli's code there were files in the DB but when i tried to check my own, there was no files.. im going to start again.. hope i can do it.. i'll try to fix the codes.. the insert query maybe has an error..
here's now my code:
Code:<?php error_reporting (E_ALL ^ E_NOTICE); $pid = base64_decode($_GET['id']); if(isset($_FILES['uploaded_file'])) { if($_FILES['uploaded_file']['error'] == 0) {$Link = mysqli_connect("localhost","root","tupi", "amyak_maleh"); if(mysqli_connect_errno()){ die("Mysql connection failed:".mysqli_connect_errno()); } $name = mysqli_real_escape_string($Link, $_FILES['uploaded_file']['name']); $data = mysqli_real_escape_string($Link, file_get_contents($_FILES ['uploaded_file']['tmp_name'])); $query = "INSERT INTO pix(pid, title, imgdata) values('$pid', '$name', '$data')"; $result = mysqli_query($Link, $query); if($result) { $asd = "Succes! YOur file was successfully added!"; $alert = base64_encode($asd); header("Location:registration.php?alert=$alert"); exit(); } else { $asd = "Error! An error occurred while the file was being uploaded. Error code:".$_FILES['uploaded_file']['error']; $alert = base64_encode($asd); header("Location:picul.php?alert=$alert"); exit(); } mysqli_close($Link); }
Comment
-
i used this:
Code:<input name="image" type="image" src="asdf.php?imgid=<?Php echo $form_no; ?>" width="110" height="100"/>
Code:error_reporting (E_ALL ^ E_NOTICE); $id = $_GET['imgid']; $Link = mysqli_connect("localhost","root","***", "***"); if (!$Link) { trigger_error("Could not connect", E_USER_ERROR ); } if(!isset($id) || empty($id)){ die("Please select your image!"); }else{ $query = mysqli_query($Link, "SELECT * FROM pix WHERE pid='$id' "); $row = mysqli_fetch_assoc($query); $content = $row['imgdata']; header('Content-type: image/jpg'); echo $content; }
Code:header('Content-Type: image/jpeg'); $id = $_GET['imgid']; $id = isset($_REQUEST['imgid']) ? $_REQUEST['imgid'] : false; if($id) { $Link = mysqli_connect("localhost","root","***", "***"); if(mysqli_connect_errno()) { die("Mysql connection failed:".mysqli_connect_errno()); } $result = mysqli_query($Link, "SELECT imgdata from pix where pid = '$id' "); if(is_resource($result)) { $row = mysql_fetch_row($result); header('Content-Type: image/jpeg'); echo $row['imgdata']; } }
thanks a lot...Comment
-
Comment