PHP - Trying To Get Image From Ftp Server With Php And Displaying It In Webpage.
Hi guys,
I have a page that lets you upload an image to a an ftp server. Now I am trying to create a page that will get those images and display them in a web page. I am trying to do this with php. Does anyone know if it can be done? Thanks guys, Similar TutorialsI am trying to have the data from my database display on a webpage the problem I am having is two fold one the 1. picture number is not displaying in order 2. how do I get the birth date to display in D- M - Y on webpage the output displays = 2007-05-11 <?php$con = mysql_connect("localhost","","");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("sacredfa_sacred", $con);$query = "SELECT picture_number, first_name, middle_name, first_family_name, second_family_name, birthdate, gender FROM child_info"; $result = mysql_query($query); if(!$result) { echo "There was a problem getting the data"; } else if(!$result) { echo "There were no results"; } else { echo "<b><center>Children to be sponsored</center></b><br><br>\n"; while($row = mysql_fetch_assoc($result)) { echo "<table border='1'><tr><th>Picture Number</th><th>First Name</th><th>Middle Name</th><th>First Family Name</th><th>Second Family Name</th><th>Birthdate</th><th>Gender</th></tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['picture_number'] . "</td>"; echo "<td>" . $row['first_name'] . "</td>"; echo "<td>" . $row['middle_name'] . "</td>"; echo "<td>" . $row['first_family_name'] . "</td>"; echo "<td>" . $row['second_family_name'] . "</td>"; echo "<td>" . $row['birthdate'] . "</td>"; echo "<td>" . $row['gender'] . "</td>"; echo "</tr>"; }echo "</table>"; }}mysql_close();?>() I have been working on a blog program with a tag system. When I add tags and ask to display them to a certain webpage they all appear on my WAMP environment but not my live server. Any thoughts as to why this might be? Here is the code needed to display the tags. I am not sure if maybe live servers have restrictions that might be stopping it from displaying.
This is on the main page to display the tags.
<div class="widget"> <?php echo '<h2>Tags</h2>'; echo '<ul>'; getTagCount($DBH); echo '</ul>'; ?> </div>Next here is the function from the includes file. function getTagCount($DBH) { //Make the connection and grab all the tag's TAG TABLE HAS TWO FIELDS id and name $stmt = $DBH->query("SELECT * FROM tags"); $stmt->execute(); $result = array(); $result = $stmt->fetchAll(); //For each row pulled do the following foreach ($result as $row){ //set the tagId and tagName to the id and name fields from the tags table $tagId = $row['id']; $tagName = ucfirst($row['name']); //Next grab the list of used tags BLOG_POST_TAGS TABLE HAS TWO FILEDS blog_post_id and tag_id $stmt2 = $DBH->query("SELECT count(*) FROM blog_post_tags WHERE tag_id = " . $tagId); $stmt2->execute(); $tagCount = $stmt2->fetchColumn(); //Print the following list echo '<li><a href="blog_tags.php?tagId=' . $tagId . '"title="' . $tagName . '">' . $tagName . '(' . $tagCount . ')</a></li></form>'; //End of loop - start again } }The "tags" database is structured like so id, name The "blog_post_tags" is structured like so, blog_post_id, tag_id On the WAMP server it returns all of tags while the live server only returns the first one. Any suggestions on what is going on? If you need any other info please let me know. I have one mysql table with data and accessing this data through one php script. This works fine in REDHAT 8 linux. I have shifted mysql database and the php script to new server with REDHAT RHEL4.4. now when I execute the script from website, it displays junk character (reading form mysql database through php script). There is no error in mysql database/table and script is working fine in redhat 8. I have checked php.ini for default characterset as well as set the encoding in mysql as latin1. Where else should I look/change? any idea? Hello I am having problems uploading an image through a HTML form. I want the image to be uploaded to the server and the image name to be written to the mysql database. Below is the code I am using: Code: [Select] <?php if (isset($_POST['add'])){ echo "<br /> add value is true"; $name = $_POST['name']; $description = $_POST['description']; $price = $_POST['price']; $category_id = $_POST['category_name']; $image = $_FILES['image']['name']; //file path of the image upload $filepath = "../images/"; //mew name for the image upload $newimagename = $name; //new width for the image $newwidth = 100; //new height for the image $newheight = 100; include('../includes/image-upload.php'); mysql_query("INSERT INTO item (item_name, item_description, item_price, item_image) VALUES ('$name','$description','$price','$image')"); ?> Here is the image-upload.php file code: Code: [Select] <?php //assigns the file to the image $image =$_FILES["image"]["name"]; $uploadedfile =$_FILES["image"]["tmp_name"]; if ($image) { //retrieves the extension type from image upload $extension = getextension($image); //converts extension to lowercase $extension = strtolower($extension); //create image from uploaded file type if($extension=="jpg" || $extension=="jpeg") { $uploadedfile = $_FILES['image']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png") { $uploadedfile = $_FILES['image']['tmp_name']; $src = imagecreatefrompng($uploadedfile); }else{ $src = imagecreatefromgif($uploadedfile); } //creates a list of the width and height of the image list($width,$height)=getimagesize($uploadedfile); //adds color to the image $tmp = imagecreatetruecolor($newwidth,$newheight); //create image imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); //set file name $filename = $filepath.$newimagename.".".$extension; $imagename = $newimagename.".".$extension; //uploads new file with name to the chosen directory imagejpeg($tmp,$filename,100); //empty variables imagedestroy($src); imagedestroy($tmp); } ?> Any help would be appreciated, fairly new to all this! Thanks!!! I am using a photo scrolling css animation technique
I'm not sure as far as CPU usage (on server)/(on client) and bandwith usage if loading one picture at a time to scroll versus having a line up "pre-exist" which even then, I would only have five images at a time but what if that is multiplied by 10000 users
Anyway, the current knowledge I have, I have a css animation property that takes in a photo and animates from 0% to 100% keyframe based on margins to make the scrolling happen
In the HTML section there is a list of photos, I would like there to be one line of code that is like a receiver that takes in or reads in arbitrary photo locations and puts that next to be scrolled without interrupting the main animation sequence which I'm not sure if there would be interruption. Anyway I don't know if that is possible. If someone can point out that this idea is obviously flawed then that would be great.
This isn't my ultimate solution, I have yet to see others, I'm just trying to minimize loading and lag
The other problem I have that is interesting is that I want the scrolling to stop when a person hovers over an image, and then resume... I have gotten this to work but only on one image... this is probably a matter of listing out all the key parts of the problem and seeing the solution but
When I had a list of photos that were scrolling together, I could get the whole animation to stop when hovering over the first photo and then take me somewhere (all the photos have working href's) but the animation would not stop if I hovered over any photos after the first. The animation would keep going
So I tried to animate each picture independently and that was just a cluster ****
Still working on that
If someone could point me in the right direction on the main problem of reading in photos live to work with css animation, that would be great.
Edited by greenace92, 03 December 2014 - 07:41 PM. Anyone know how I can print a file (specifically a PDF) that is stored on the server to the clients computer with a button? I don't want them to be able to view it, just print it. I've done some research and understand that there is no way to print directly without popping up the Windows Print dialog. And that is fine. I just want them to print this file, but not no where it is or be able to type in a URL to access it. Thanks Mike Hi there! im new to php , im having problem when upload image to server. Hope somebody can help me. i upload picture in admin CMS, the pic able to save in mysql but is not save in my server, the script below : Code: [Select] $catImage = uploadImage('fleImage', SRV_ROOT . 'images/category/'); i have check the folder/directory name all correct but the picture wont save in my server images folder & i try this script but not working as well: Code: [Select] $target_path = "images/category/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); i got this tutorial from : http://www.phpwebcommerce.com/ Thank You In Advance I have a PHP script that locates a photo in a MySQL database and based on the path /filename stored in the database, retrieves the file and downloads it via the browser, the problem is that it saves as a filename that is the url with no extension. so we pass : dlfile.php?id-10 the script is supposed to get the filename from the stored file and download it with that filename but it downloads the file as 'dlfile?id=10' instead of PIC76534.jpg. where am i going wrong? code below for dlfile.php. or is there a way to ask the user to select a filename when downloading? I know the script is crude but have had it for ages. <?php require( '../js/db.php' ); $id = $_GET[ 'id' ]; $sql = "SELECT * FROM image_archive WHERE id = " . $id; $result = mysqli_query( $conn, $sql ); if ( !$result ) { echo "ERROR: " . mysqli_error( $conn ); } else { $row=mysqli_fetch_assoc($result); //path to the picture you're wanting the viewer to download $path = "/archimages/".basename($row['pic_OriginalPath']); if ( file_exists( $path ) ) { //split the extension and name from eachother $e = explode( '.', $path ); //get the name of the file $file_name = $e[ 0 ]; //image extension $extension = $e[ 1 ]; // Send a header saying we'll be displaying a picture header( 'Content-type: '.$row['pic_Type'] ); // Name the file header( 'Content-Disposition: attachment; filename="' . $file_name . $extension . '"' ); // Path to the picture you're wanting the user/viewer to download readfile( $file_name . '.' . $extension ); } else { echo 'The requested image does not exist.'.$path.'<hr>'; } } ?>
Hi, I deleted my image in the server folder, but still my image is showing, what might be the problem, Confused, I have cleared my browser cache and restarted, but nothing helps me, if anyone have idea about this pls share with me Thanks, Hello I have uploaded images from a server onto a website, they run through a mysql database (database holds the image file names). The problem I am having is resizing the images. Can anyone help? Thank you in advance GWG I need to upload an image using php and store the image as blob in mysql. I understand the standard way is to create a form for the user, let the user choose the image to upload, click submit. But I need to create a php, for example, uploadImage.php?image="c:\myPhoto.jpg" and when I type http:\\www.myhome.com\uploadImage.php?image="c:\myPhoto.jpg" from a web browser in my pc, I can automatically upload myPhoto.jpg to the myhome.com server? Thank you for your kind help. i need to count the number of image files on a remote server not in my network. ive come across a suggestion to use
@getimagesize($img_url)the above works but is really slow. anyone able to suggest a better method? I am using this code Code: [Select] <?php echo IMAGES_HEADER . "header_02.jpg"; ?> Instead of displaying the actual image on my site I am getting the path of the image. It is displaying "images/header/header_02.jpg" instead. Thank You in advance i have a db which store jpg image thru the upload prg code in php.But the image is not displayed properly in the <img> and also when i echo the blob data. how to correct this code.i am pasting the code below $result = mysql_query("select cover from Movies where movie_id=4"); $row = mysql_fetch_row($result); $data = base64_decode($row[0]); $im = imagecreatefromstring($row[0]); imagejpeg($im); header('Content-type: ' . $mime); // 'image/jpeg' for JPEG images echo $data; <img src=<?php echo $data;?>> try { echo "<br>"; foreach($dbh->query("SELECT * FROM test_shot WHERE sold=1 ORDER BY year ASC") as $row) { if($row['picture'] != "" && $row['picture'] != null) { echo "<div class='image-holder'><img src ='".$row['picture']."' width=300px /><br>"; } if($row['year'] != "" && $row['year'] != null) { echo $row['year']; } if($row['description'] != "" && $row['description'] != null) { echo $row['description']; } if($row['sold'] == 1) { echo "<img src='images/sold1.png'><br>";//Add your image code here } elseif ($row['sold'] == 0) { echo "</div><br>"; } } } catch (PDOException $e) { print $e->getMessage(); } ?>
I am having trouble with displaying an image from a url. In the following code if I echo out $test I get the url of the image. However, in the current code I am trying to display the image, but the only thing that gets displayed is a small broken image in the upper left.
$html = file_get_contents($website.$criteria); $dom = new DOMDocument; @$dom->loadHTML($html); $links = $dom->getElementsByTagName('img'); header('Content-Type: image/png'); foreach ($links as $link){ $test = $link->getAttribute('src'); echo file_get_contents($test); }image that gets displayed: http://imgur.com/epfF3wJ I must be doing something incredibly daft, because I'm incredibly new at this. I have an image stored in a DB under a table called 'images' and I want to display it on my website but instead of that image I get the error: Warning: Cannot modify header information - headers already sent by (output started at /home/... This is how I'm trying to achieve it. Any ideas where I'm doing wrong? Thanks. Code: [Select] <?php $user="###"; $password="###"; $database="###"; $con = mysql_connect(localhost,$user,$password); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($database, $con); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>MySite</title> </head> <body> <div id="container"> <?php include("../navbar.php"); ?> <div id="left-content"></div> <div id="right-content"> <?php $item = $_GET['item']; $query = "SELECT * FROM main WHERE Ref='$item'"; $result = mysql_query($query) or die("Oops" .mysql_error()); $row = mysql_fetch_array($result,MYSQL_BOTH) or die("Oops" .mysql_error()); extract($row); $query2 = "SELECT image FROM main WHERE Ref='$item'"; // the result of the query $result2 = mysql_query($query2) or die("Invalid query: " . mysql_error()); header("Content-type: image/jpg"); echo mysql_result($result2, 0,'image'); echo "<p><strong>Name: </strong>".$FirstName." - ".$SecondName."</p>"; mysql_close($con); ?> </div> <br /> <?php include("../footer.php"); ?> </div> </div> </body> </html> MOD EDIT: [code] . . . [/code] BBCode tags added. Good day: Im trying to display an image from a folder and the image name is retrieved by a query. The query is getting the image name all right but the image is not displaying. This is the code im using for the image display Code: [Select] <?php $aid = 1; $connection = mysql_connect("localhost", "username", "password"); mysql_select_db("articles", $connection); $query="SELECT imagename, description FROM articles_description WHERE id='$aid'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table width ="1000" border="1" cellspacing="2" cellpadding="2"> </tr> <?php $j=0; while ($j < $num) { $f8=mysql_result($result,$i,"description"); $f9=mysql_result($result,$i,"imagename") ?> <tr> <td valign="top"> <img src="images/'.$f9.'; ?>" alt="" name="picture" width="100" height="100" border="1" /></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f8; ?></font></td> </tr> <tr> </tr> <?php $j++; } ?> Any help will be appreciated Now I am trying to display the images from my table and I have almost got it working, except for one small thing --- it seems to be displaying all the records, but instead of displaying the right image for each record, it's displaying the same image across all the records. Can anyone tell me what I have done wrong? Code: [Select] this is the gallery <?php $dbhost = 'localhost'; $dbuser = 'webdes17_lizkula'; $dbpass = 'minimoon'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'webdes17_jewelry'; mysql_select_db($dbname); $all_records = "SELECT * FROM gallery"; $all_records_res = mysql_query($all_records); $image = mysql_result($all_records_res, 0, 'image'); while($nt=mysql_fetch_array($all_records_res)){ echo "<img src=http://www.webdesignsbyliz.com/wdbl_wordpress/wp-content/themes/twentyten_2/upload/$image>"; } ?> I'm guessing I have the $image variable in the wrong place, but when I tried placing it within the while statement, the page never loaded, and instead acted like it was loading forever. What am I doing wrong? Here is the link to the page so you can see what is happening: http://webdesignsbyliz.com/wdbl_wordpress/test-submit/ I just can't get anything right today! Now I am trying to have a list of images, and when the user clicks on the image, the next page will display the image along with other fields for that record. I am sending the id through the hyperlink to the next page, and I have echoed it to ensure it's comign through, but I cannot get anythign to display ont he next page. What am I doin wrong? Here is the link to the page. If you click on one of the images, you 'll see that the next page is empty: http://webdesignsbyliz.com/wdbl_wordpress/test-submit/ Here is my code: Code: [Select] this is the gallery <?php $dbhost = 'localhost'; $dbuser = 'user'; $dbpass = 'pass'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'jewelry'; mysql_select_db($dbname); $all_records = "SELECT * FROM gallery"; $all_records_res = mysql_query($all_records); $image = mysql_result($all_records_res, 0, 'image'); $id = mysql_result($all_records_res, 0, 'id'); while($nt=mysql_fetch_array($all_records_res)){ echo "<a href=http://webdesignsbyliz.com/wdbl_wordpress/test-display/?id=" .$nt['id']." ><img src=http://www.webdesignsbyliz.com/wdbl_wordpress/wp-content/themes/twentyten_2/upload/".$nt['image']." width=133 height=86></a>"; } ?> display page: Code: [Select] <?php $id = $_GET['id']; $dbhost = 'localhost'; $dbuser = 'user'; $dbpass = 'pass'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'jewelry'; mysql_select_db($dbname); $all_records = "SELECT * FROM gallery WHERE id = $_GET[id]"; $all_records_res = mysql_query($all_records); $image = mysql_result($all_records_res, 0, 'image'); $id = mysql_result($all_records_res, 0, 'id'); while($nt=mysql_fetch_array($all_records_res)){ echo "<img src=http://www.webdesignsbyliz.com/wdbl_wordpress/wp-content/themes/twentyten_2/upload/".$nt['image']." width=133 height=86></a>"; } ?> What an I doing wrong this time?? :-( |