Hy guys. I want to take a drawing from a canvas instead of saving it as an image like this https://github.com/eligrey/FileSaver.js .I want to upload it to my local server mysql using php.
please help
<?php
$conn = new mysqli("localhost","root","","userdetails");
$results = $conn->query("SELECT * FROM userInfo");
while($row = $results->fetch_assoc()){
echo "Name :".$row['uname'].
"<br/>Surname : ".$row['surname'].
"<br/> Image : <img width='200' height='100' src='images/".$row['userImage']."' />";
}
#$uname = $_POST['uname'];
#$surname = $_POST['surname'];
#$image = $_POST['img'];
if(isset($uname)){
$conn->query("INSERT INTO userInfo values('','$uname','$surname','$image')");
move_uploaded_file($image, '../images/'.basename($image));
}
?>
Related
I am trying to hide video (videos/mymovie.mp4) URL so as to make video downloading difficult. I am using session id and video path to get a encrypted token. Below is my code for sublime player (video.php).
<?php
include('movie_url.php');
echo '<video id="'.$movieId.'" class="sublime" poster="'.$cover_image_path.'" width="935" height="526" title="'.$movie_title.'" data-autoresize="fit" preload="none">
<source src="moviesessionurl.php?video='.$hash.'" />
</video>';
?>
movie_url.php contains
<?php
//Connect to database
include("config.php");
session_start();
$sid = session_id();
$movieId = $_SESSION['movie_id'];
$sql = "SELECT * FROM `movies` WHERE intMovieID = ".$movieId;
$result = mysqli_query($con,$sql);
$row = mysqli_fetch_row($result);
$movie_title = $row[1];
$movie_desc = $row[7];
$trailer_path = $row[8];
$movie_path = $row[9];
$cover_image_path = $row[10];
$still_image_path = $row[11];
$poster_image_path = $row[12];
$movie_duration = $row[16];
$hash = md5($movie_path.$sid);
$_SESSION[$hash] = $movie_path;
mysqli_close($con);
?>
And moviesessionurl.php contains
<?php
/* start the session */
session_start();
$path = $_SESSION[$_GET['video']];
echo $path;
?>
when i run the moviesessionurl.php directly in browser i get the correct video url. But when I run video.php which contains sublime player the video doesn't play! Gives the error "Cant play video"
Please help me get this done.
That won't work, it is looking for video content at the url moviesessionurl.php I would reccomend fetching the url through an AJAX request. Then dynamically creating the video element once the URL has been retreived.
Iv try to display BLOB-1B content or image in PHP, I have an app in Android that take an image then upload to my host mysql I have no problem with upload now its time to display in PHP, here is my code.
//config.php
public function _owners_img($stall_id){
$request ="SELECT `img` FROM `img_stall` WHERE `stall_id` = '$stall_id' LIMIT 1";
$result_query = $this->con->query($request);
while($data = $result_query->fetch_assoc()){
$result_data = $data['img'];
}
if (!empty($result_data)) {
return $result_data;
}else {
return false; }
}
//owner_img.php
include_once 'config.php';
$db = new database($con);
$db->dbconnect();
$owner = 3;
echo "<dt><strong>Stall Image:</strong></dt><dd>" .
'<img src="data:image/jpeg;base64,'.
base64_encode($db->_owners_img($owner)).
'" width="290" height="290">' . "</dd>";
but the problem is Am only getting small image icon or image not found. how do I fix this?
I'm new to php. I have a sample mysql db in that I have a table named testdb with columns id(INT) and image(BLOB). I have uploaded an image into testdb. Uploaded successfully. The following is the php code. The variable $conn contains the connection details. I have a html page which redirects to this php page on submitting.
<?php
$name = $_FILES["sample"]["name"];
echo $name . "<br/>";
$tmp_name = $_FILES["sample"]["tmp_name"];
echo $tmp_name . "<br/>";
$size = $_FILES["sample"]["size"];
echo $size . "<br/>";
$contents = file_get_contents($tmp_name);
$htmlen = htmlentities($contents);
$cont = mysql_real_escape_string($contents);
$query = "INSERT INTO testdb(image)
VALUES ('$cont')";
$dbquery = mysql_query($query, $conn);
if($dbquery){
echo "successfully inserted";
}
else{
echo "could not inserted" . mysql_error();
}
?>
I am trying to get the image with the following code. But it is showing string characters rather than the image. As far as I know this should work fine.
<?php
$query = "SELECT image, id
FROM testdb ";
$dbquery=mysql_query($query , $conn);
if(! $dbquery){
echo "Could not selected the data from database. " . mysql_error();
}
while( $row = mysql_fetch_array($dbquery) ){
$decodeimg = html_entity_decode($row["image"]);
echo "<img src= $decodeimg/><br/> hellow orld <br/>";
}
?>
Could anyone help me with this. Thanks in advance.
Instead of storing the actual image in your database (which is redundant because it is probably stored on your server too); why don't you just store the PATH to the image as a string, query the string from your db and then append it to the 'src' attribute with php.
I am also got the same error when show the BLOB image from DB. I just use the decoding method for this problem....
$photo=$myrow['image'];
echo '<img src="data:image/jpeg;base64,' . base64_encode( $photo ) . '" width="150" height="150" />
I know this question has been asked many times but I couldnot solve this using any of them.
I am new to sqlite and cannot understand what I am doing wrong.
WHAT I AM TRYING
I am trying to make a profile view page. I am able to fetch all details from my sqlite database but i am not able to display my profile picture.
TABLE STRUCTURE
**username|landline|mobile|email|profilepicture**
john |xxxxxxxx|xxxxxx|x#x.x|blob
WHAT I TRIED
$sql = "SELECT * FROM profile";
$query = $db->query($sql);
while($row = $query->fetchArray(SQLITE3_ASSOC) ){
echo "NAME = ". $row['user_name'] . "<br/>";
echo "LANDLINE = ". $row['user_landline'] ."<br/>";
echo "MOBILE = ". $row['user_mobile'] ."<br/>";
echo "EMAIL = ".$row['user_email'] ."<br/>";
header('Content-Type: image/png');
echo $row['user_profile_picture'];
}
<html>
<img src='profile.php?imgid=<?php echo $row['user_profile_picture'];?>'/>
</html>
But the image dosenot show and also the rest of the data dosenot display when i putheader('Content-Type: image/png');
Create an image.php:
<?php
$sql = "SELECT user_profile_picture FROM profile WHERE id = " . $_GET['id'];
$query = $db->query($sql);
$row = $query->fetchArray(SQLITE3_ASSOC);
header('Content-Type: image/png');
echo $row['user_profile_picture'];
In profile.php:
<img src='image.php?id=<?php echo $row['id'];?>'/>
thank's for help. I have problem displaying images retrieving from my database.
I cant see the image when loading image.php in img src or directly from the page. When i display the variable without header('Content-type: image/jpeg'); i can see all the code inside, as i put this line all goes off.
I have a table called TABLE with id, title, img stored as longblob directly uploaded inside phpmyadmin.
Can anyone help me?
index.php
<?php
session_start();
include "admin/include/connection2.php";
$data = new MysqlClass();
$data->connect();
$query_img ="SELECT * FROM table ORDER BY data ASC LIMIT 4";
$post_sql = $data->query($query_img);
if(mysql_num_rows($post_sql) > 0){
while($post_obj = $data->estrai($post_sql)){
$id = $post_obj->id;
$titolo = stripslashes($post_obj->title);
$data_articolo = $post_obj->data;
$immagine = $post_obj->img;
// visualizzazione dei dati
echo "<h2>".$titolo."</h2>";
echo "Autore <b>". $autore . "</b>";
echo "<br />";
echo '<'.'img src="image.php?id='.$post_sql['id'].'">';
echo $id;
echo "<hr>";
}
}else{
echo "no post aviable.";
}
// here is the image.php code
<?php
include "admin/include/connection2.php";
$data = new MysqlClass();
// connect
$data->connetti();
$id = $_GET['id'];
echo $id;
$query = mysql_query("SELECT * FROM articoli_news WHERE id='".$id."'"; //even tried to send id='1' but not working
echo $query;
$row = mysql_fetch_array($query);
echo $row['id']; //correct displaying
$content = base64_decode($query['img']);
header('Content-type: image/jpeg');
echo $content;
?>
Delete all "echo" commands except "echo $content;" because there are also appear in the output, and damage your image.
And use ob_start(); in the begining of the script, and check out your script file not contain any of whitespace characters before or after the php begint and close tags .