Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

- - - - -

Tutorial: Storing Images in MySQL with PHP / Part II / Display your images

mysql

  • This topic is locked This topic is locked
213 replies to this topic

#13 Guest_Jaan_*

Guest_Jaan_*
  • Guest

Posted 11 July 2008 - 04:24 AM


// .rar
$allow_type = "application/rar";
// .zip
$allow_type = "application/zip";


I get those by using this script:



<?php
if($_GET['act'] == "show"){
echo $_FILES['files']['type'];
}else{
?>

<form action="?act=show" enctype="multipart/form-data" method="post">
<input type="file" name="files" />
<input type="submit" name="submit" />
</form>
<?php
}
?>


  • 0

#14 coated_pill

coated_pill

    CC Newcomer

  • Just Joined
  • PipPip
  • 12 posts

Posted 12 July 2008 - 07:40 PM


// .rar
$allow_type = "application/rar";
// .zip
$allow_type = "application/zip";


I get those by using this script:



<?php
if($_GET['act'] == "show"){
echo $_FILES['files']['type'];
}else{
?>

<form action="?act=show" enctype="multipart/form-data" method="post">
<input type="file" name="files" />
<input type="submit" name="submit" />
</form>
<?php
}
?>


by the way.. can i have a very detailed tutorials on how can i upload my files to my sub folder in my public_html folder..

A step step by step to do this with the explanation and example.. that would be highly appreciated.. thanks! i am just a newbie in php..

Thank you again!
  • 0

#15 coated_pill

coated_pill

    CC Newcomer

  • Just Joined
  • PipPip
  • 12 posts

Posted 12 July 2008 - 10:31 PM

Resolved ^_^
  • 0

#16 -z-

-z-

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 20 July 2008 - 10:00 AM

hi.. i have modified the code because i did not pass the id from other page.. an while i run the page .. it will call me to download the php file...pls advice .. i just want to retrieve the picture stored in the database and it is uploaded sucessfully from the previous tutorial provided.. thanks in advance

 $storedid = "1";
  $id = (int)$storedid;

if(!isset($id) || empty($id)){
die("Please select your image!");
}else{

$query = mysql_query("SELECT * FROM tbl_images WHERE id='$id'");
$row = mysql_fetch_array($query);
$content = $row['image'];

  • 0

#17 Stucka

Stucka

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 11 August 2008 - 09:25 AM

Thank you
  • 0

#18 techker

techker

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 131 posts

Posted 23 August 2008 - 01:31 PM

why is that i get a download file when i call it in the browser?

viewimage.php?id=1
  • 0

#19 Guest_Jaan_*

Guest_Jaan_*
  • Guest

Posted 24 August 2008 - 04:17 AM

hmm.. have you changed anything?
  • 0

#20 techker

techker

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 131 posts

Posted 24 August 2008 - 04:25 AM

nothing at all...
  • 0

#21 wendellrt

wendellrt

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 01 September 2008 - 06:38 AM

Hello Everyone.

When I use the example code, all I get is a blank (all white) page being displayed in my browser ('view source' displays a blank page as well).

Where did I go wrong???
  • 0

#22 wendellrt

wendellrt

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 01 September 2008 - 06:50 AM

You could try putting the following...
header('Content-type: image/jpg');
before the line which reads...

echo $content;
HTH.

Edited by Jaan, 13 October 2008 - 10:36 AM.
Please use code tags when you're posting your codes!

  • 0

#23 casper3000ah

casper3000ah

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 12 September 2008 - 07:08 AM

thank you for ur effort

thanks man :)


  • 0

#24 billjones

billjones

    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 13 October 2008 - 09:45 AM

Hi , Jaan
Can you help a newbie ?
I can upload images into the database with no problems, but retrieving them is a problem, they come out of the database in a raw form, its as if the following code is not working !

header('Content-type:image/jpg');

it does not seem to have an effect, if I delete this part of the code I get the same result! Raw data. Can you help?

Edited by billjones, 13 October 2008 - 10:10 AM.

  • 0