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.
Related
I have some images in a database which I would like to add to a html page
This is my current code
<div class = "gridrow">
<?php
foreach (range(1, 4) as $value) {
$result = $conn->query("select * from products where product_ID = '".$value."'");
$row = $result->fetch_array();
$name_p1 = $row['product'];
$price_p1 = $row['price'];
$image = "<img src='{$row['image']}'>";
echo "<div class = 'productwindow' >";
echo "<div class = 'productimage'><".$image."></div>";
echo "<div class = 'productvar'><p>".$name_p1."</p></div>";
echo "<div class = 'productvar'><p>$".$price_p1."</p></div>";
echo "</div>";
}
?>
</div>
This is what the page looks like
These are the errors I get
How can I make these images show correctly?
You're storing image data in the database, while the img src tag wants image URLs, that's why it's getting confused and you're getting errors.
The quick way around it is to convert the image data to base64 and pipe it in the src tag like so:
$image = '<img src="data:image/png;base64,'.base64_encode($row['image']).'">';
This is at best a hack, and not a great idea for a host of reasons, it also assumes all your images are PNG.
am trying to display images page A but calling them from page B. images are contained in the images folder and database table images
my page a code is
<img src="addimage.php?image_id=<?php echo $row["code"]; ?>" />
page B code is
<?php
require_once "db.php";
if(isset($_GET['image_id'])) {
$sql = "SELECT image FROM images WHERE code=" . $_GET['image_id'];
$result = mysqli_query($mysqli, $sql) " . mysqli_error($mysqli));
$row = mysqli_fetch_array($result);
echo $row["image"];
}
mysqli_close($mysqli);
?>
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));
}
?>
A friend of mine wrote this script, displaying the 20 most recent instagram images, and I was wondering, how can I change the amount of images it grabs to maybe, 6?
<?PHP
$token = 'token';
$username = 'username';
$userInfo = json_decode(file_get_contents('https://api.instagram.com/v1/users/search?q='.$username.'&access_token='.$token));
if($userInfo->meta->code==200){
$photoData = json_decode(file_get_contents('https://api.instagram.com/v1/users/'.$userInfo->data[0]->id.'/media/recent/?access_token='.$token));
if($photoData->meta->code==200){ ?>
<?PHP foreach($photoData->data as $img){
echo '<img src="'.$img->images->thumbnail->url.'">';
} ?>
<?PHP } // If
} // If
?>
Now, the script is functional now because I've been working on it all day, but I'm not sure how to change how many it sends out.
Also, would any of you know how to style this? I already have the CSS done for it, but whenever I try it, it doesn't work correctly.
And, would you know how to get the description of the photo using the API?
Thank you in advance :-)
You need to use Instagram's count= url parameter when requesting data from their endpoints.
For example: https://api.instagram.com/v1/users/search?count=6
Or in your code:
<?PHP
$token = 'token';
$username = 'username';
$userInfo = json_decode(file_get_contents('https://api.instagram.com/v1/users/search?count=6&q='.$username.'&access_token='.$token));
if($userInfo->meta->code==200){
$photoData = json_decode(file_get_contents('https://api.instagram.com/v1/users/'.$userInfo->data[0]->id.'/media/recent/?count=6&access_token='.$token));
if($photoData->meta->code==200){ ?>
<?PHP foreach($photoData->data as $img){
echo '<img src="'.$img->images->thumbnail->url.'">';
} ?>
<?PHP } // If
} // If
?>
Pseudo example for styling. You'll need to figure out the css styles for that, but shouldn't be to difficult.
<div class='myBorder'>
<img url=$img->link />
<div class='myCaption'>$img->caption->text</div>
</div>
To get the description
if (isset($img->caption)) {
if (get_magic_quotes_gpc()) {
$title = stripslashes($img->caption->text);
} else {
$title = $img->caption->text;
}
}
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 .