I wanna get a functional download/videostreaming link, i'm trying this through
Openload and pCloud API, but I always getting error when I put my script in anywhere outside my localhost.
My pCloud code is:
<?
ini_set('display_errors','0');
echo '<form method="POST" enctype="multipart/form-data" id="add-row-form" action="">';
echo "<input type='text' value='XZ1Ix57ZIVJU5FGmV8bkvWwukuJ0JBkIKJzX' placeholder='ID da Série' name='tvshowid'></input>";
echo "<button name='ok' type='submit'>Tudo certo</button>";
echo '</form>';
$query = $_POST['tvshowid'];
$lang = $_POST['lang'];
if(isset($_POST['ok'])) {
$postdata = file_get_contents("https://api.pcloud.com/getpublinkdownload?code=". $query);
$request = json_decode($postdata);
print_r($request);
$theData = $request;
$host = $theData->hosts[rand(0,1)];
$path = $theData->path;
$vlink = 'https://'.$host. $path;
echo '<div>';
echo '<video width="30%" height="auto" controls autoplay>
<source src="'.$vlink.'" type="video/mp4">
</video>';
echo "</div>";
}
?>
Preview
Always when i try to generate a link, it says "This link was generated for another IP address. Try previous step again."
The question is: How can I get data from a JSON through my user's IP or server adrres and not by my server address (as has been happening), so that the video link is valid?
Related
I have to scrape data from google.
For example, this URL:
https://www.google.com/searchbyimage?&image_url=https://traum-deutung.de/wp-content/uploads/2016/04/traumdeutung-offener-sarg-symbol-768x768.jpg
but when I scrape it and echo the data variable, it simply shows me the google page like this:
This is actual result from google image search but I didn't find its code in my php script:
the code i use for this
<?php
require 'simple_html_dom.php';
$link = $_GET['link'];
if (!isset($link) || empty($link)) {
echo "please provide a link". "<br> \n";
echo "EXAMPLE : <br>";
echo "example.com?link=HERE PUT IMAGE LINK";
die();
}
$html = file_get_html('https://www.google.com/searchbyimage?&image_url='. $link);
echo $html;
?>
I need to have a working remote IMG display using PHP, let's say like this:
<img src='$src' />
And I need to fetch the remote URL based on $id, where
<?php
$id = "brown_fox";
$url = "http://exampl.com/$id";
get_remote_img($url) {
// some code to get image which SRC is dynamic:
<img id="pic" src="sjf5d85v258d.jpg" />
$src="sjf5d85v258d.jpg";
return $src
}
?>
I hope I explained it understandably.
If I understand you correctly then you can do something like this:
<?php
...
get_remote_img($url) { ...
$src = get_remote_img($url);
// Concatenating the result to the elements src attribute:
echo '<img src='.$src.' />';
?>
What you're looking for is something like this:
<?php
$id = "brown_fox";
$url = "http://exampl.com/" . $id;
...
function get_remote_img($url) {
// some code to get image which SRC is dynamic:
$src="sjf5d85v258d.jpg";
echo "<img id=\"pic\" src=" . "\"" . $src . "\"" . "/>";
return $src;
}
?>
Also, if you want to send and receive query parameters in the URI dynamically through a form, you can take a look at GET Request in PHP.
We are hosting a WordPress site on our own Windows server its working fine, but few days back realized that there is a PHP contact form which sends a PDF attachments with radio buttons, which works fine when it was Hosted on Godaddy, now the problem is radio buttons are not loaded cos I see the URL is
<img src=\"$SITE_URL/patientform/ckedimage.png\"/>
and the $site_url is
$SITE_URL="http://".$_SERVER['SERVER_NAME'];
I think its pulling up the local server name,how do I set the Site URL as domain.com ?
whole code
<?php
$SITE_URL="http://".$_SERVER['SERVER_NAME'];
$cnt1=1;
foreach($caffinarr as $sympKey=>$sympVal6)
{
if(in_array($sympVal6, $caffinevalue))
{
$html .="<td><img src=\"$SITE_URL/patientform/ckedimage.png\"/>
<td>$sympVal6 </td>";
}
else
{
$html .="<td><img src=\"$SITE_URL/patientform/uncheckedimage.png\"/>
<td >$sympVal6</td>";
Fix your code to
<?php
$SITE_URL = 'http://'.$_SERVER['SERVER_NAME'];
$dir = "/patientform/ckedimage.png";
//echo $SITE_URL.$dir;
?>
<img src="<?php echo $SITE_URL.$dir; ?>" />
This is how your code would be:
<?php
$SITE_URL = 'http://'.$_SERVER['SERVER_NAME'];
$dir = "/patientform/ckedimage.png";
$dir_uncheck = "/patientform/uncheckedimage.png";
//echo'<img src="'.$SITE_URL.$dir.'" />';
$cnt1=1;
foreach($caffinarr as $sympKey=>$sympVal6)
{
if(in_array($sympVal6, $caffinevalue))
{
$html ='<td><img src="'.$SITE_URL.$dir.'" />
<td>'.$sympVal6.'</td>';
echo $html;
}
else
{
$html ='<td><img src="'.$SITE_URL.$dir_uncheck .'" />
<td>'.$sympVal6.'</td>';
echo $html;
?>
I have a problem in using $_FILES and $_POST at the same the because I have a form to upload an image and some data bus when I use one of them it works but when I used the other one id doesn't work.
my code is :
<?php
include 'debugging.php';
//phpinfo();
echo '<br />';
echo '<h1>Image Upload</h1>';
//create a form with a file upload control and a submit button
echo <<<_END
<br />
<form method='post' action='uplaodex.php' enctype='multipart/form-data'>
Select File: <input type='file' name='picName' size='50' />
name: <input type='text' name='usName' size='50' />
username : <input type='text' name='usUsername' size='50' />
pass: <input type='password' name='usPass' size='50' />
email: <input type='text' name='usEmail' size='50' />
<br />
<input type='submit' value='Upload' />
<input type="hidden" name="submit" value="1" />
</form>
<br />
_END;
//above is a special use of the echo function - everything between <<<_END
//and _END will be treated as one large echo statement
//$_FILES is a PHP global array similar to $_POST and $_GET
if (isset($_FILES['picName'])and isset($_POST['submit'])) {
//we access the $_FILES array using the name of the upload control in the form created above
//
//create a file path to save the uploaded file into
$name = "images//" . $_FILES['picName']['name']; //unix path uses forward slash
//'filename' index comes from input type 'file' in the form above
//
//move uploaded file from temp to web directory
if (move_uploaded_file($_FILES['picName']['tmp_name'], $name)) {
// Create the file DO and populate it.
include 'Do_profile.php';
$file = new Do_profile();
//we are going to store the file type and the size so we get that info
$type = $_FILES['picName']['type'];
$size = $_FILES['picName']['size'];
$usName = trim($_POST['usName']);
$usUsername = trim($_POST['usUsername']);
$usPass = trim($_POST['usPass']);
$usEmail = trim($_POST['usEmail']);
$file->FileName = $name; //$name is initialised previously using $_FILES and file path
$file->FileSize = $size;
$file->Type = $type;
$file->usName = $usName;
$file->usUsername = $usUsername;
$file->usPass = $usPass;
$file->usEmail = $usEmail;
if ($file->save()) {
//select the ID of the image just stored so we can create a link
//display success message
echo "<h1> Thankyou </h1><p>Image stored successfully</p>";
//this above line of code displays the image now stored in the images sub directory
echo "<p>Uploaded image '$name'</p><br /><img src='$name' height='200' width='200'/>";
//create alink to the page we will use to display the stored image
echo '<br><a href="Display.php?id=' . $fileId . '">Display image ' .
$file->FileName . '</a>';
} else
echo '<p class="error">Error retrieving file information</p>';
}
else {
echo '<p class="error"> Oh dear. There was a databse error</p>';
}
} else {
//error handling in case move_uploaded_file() the file fails
$error_array = error_get_last();
echo "<p class='error'>Could not move the file</p>";
// foreach($error_array as $err)
// echo $err;
}
echo "</body></html>";
?>
I don't know what is the problem, any help??
Everything inside that if (isset($_FILES['picName'])and isset($_POST['submit'])) doesn't work because the superglobal $_FILES is probably not having a key named picName. To check this out, try var_dump-ing the $_FILES, like var_dump($_FILES);
By the output of the var_dump you'd get to know if there is any content inside $_FILES. And if it is populated, just see what the key name is and, access the file by using that key.
But if the array is empty, there may be some mis-configurations in PHP, or APACHE.
One possible fix would be setting file_uploads = On in the ini file for php.
Hope it helps!
You have to validate the size of the file if you want to do an isset. I don't know if this is works, but the better way for do that is check first the size for validate if isset or was send to the server.
Then, in your <form method='post' action='uplaodex.php' enctype='multipart/form-data'> you have to create another PHP file with the name uplaodex.php where you'll send al the data. So, your code with be like the below code following and considering the step 1. This will be your uploadex.php
$name_file = $_FILES['picName']['name'];
$type = $name_file['type'];
$size = $name_file['size'];
$tmp_folder = $name_file['tmp'];
$usName = trim($_POST['usName']);
$usUsername = trim($_POST['usUsername']);
$usPass = trim($_POST['usPass']);
$usEmail = trim($_POST['usEmail']);
if ( $size > 0 ) {
//REMOVE another slash images//
$name = "images/" . $name_file; //unix path uses forward slash
//'filename' index comes from input type 'file' in the form above
//
//move uploaded file from temp to web directory
if ( move_uploaded_file($tmp_folder, $name) ) {
// Create the file DO and populate it.
include 'Do_profile.php';
$file = new Do_profile();
$file->FileName = $name; //$name is initialised previously using $_FILES and file path
$file->FileSize = $size;
$file->Type = $type;
$file->usName = $usName;
$file->usUsername = $usUsername;
$file->usPass = $usPass;
$file->usEmail = $usEmail;
if ($file->save()) {
//USE PRINTF
printf('<h1> Thankyou </h1><p>Image stored successfully</p><br>
<p>Uploaded file: %s</p>. <img src="%s" height="200" width="200" />',
$name_file, $name );
#WHAT IS $fileId? In which moment was define?
//echo '<br><a href="Display.php?id=' . $fileId . '">Display image ' .
$file->FileName . '</a>';
}
else
echo '<p class="error">Error retrieving file information</p>';
}
else {
echo '<p class="error"> Oh dear. There was a databse error</p>';
} //ENDIF OF if (move_uploaded_file($_FILES['picName']['tmp_name'], $name))
} //ENDIF OF if ( $size > 0 )
#ELSE OF YOUR if ( $size > 0 )
else {
//error handling in case move_uploaded_file() the file fails
$error_array = error_get_last();
echo "<p class='error'>Could not move the file</p>";
// foreach($error_array as $err)
// echo $err;
}
I solved the problem, you can't perform $_FILES and $_post at the same time or one of them inside the other.
start with $_Post and then $_FILES and outside the $_FILES run your saving function
thats it
I have stored images path in database and images in project folder. Now i am trying to view all IMAGES with their PRODUCTS in my HTML template. I have written the following code and its given me an empty images box in the output and when i open that image box in the new tab, it opens the following URL.
http://localhost/cms/1
Kindly tell me the way of referring images in 'img src ' tag.
include 'connect.php';
$image_query = "select * from product_images";
$image_query_run = mysql_query($image_query);
$image_query_fetch = mysql_fetch_array($image_query_run);
if (!$query=mysql_query ("select product_id,name from products")) {
echo mysql_error();
} else {
while ($query_array = mysql_fetch_array($query)) {
echo '</br><pre>';
$product_id = $query_array['product_id'];
echo "<a href='single_product.php?product_id=$product_id' >";
print_r ($query_array['name']);
echo "</a>";
echo "<img src=". $image_query_fetch
['images'] ." alt=\"\" />";
echo '</pre>';
}
}
} else {
echo "You need to Log in to visit this Page";
}
Add your local image path before source
example
echo "<img src='http://localhost/cms/1/". $image_query_fetch['images'] .'" alt=\"\" />";
*Use PHP *
<?php echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>
You can use the HTML base tag to set a base URL that relative URLs will be resolved from.
See -> http://www.w3schools.com/tags/tag_base.asp