Author Topic: display images on word document  (Read 659 times)

prajakta

  • Regular Member
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
display images on word document
« on: December 29, 2011, 01:23:44 AM »
hie everyone....
i want to display images on word document thru php coding... i have successfully generated the word document evn it is displaying all other data from database except images...it is showing the path on word page instead of image...
whats the problem...i have used the same path of images in other applications to display images....

jSherz

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 409
  • Karma: +4/-0
    • View Profile
    • jSherz.com
Re: display images on word document
« Reply #1 on: December 30, 2011, 06:53:47 AM »
Please can you post the source code for the PHP file that creates the document?
Looking for PHP tutorials? View mine. Please use code or PHP tags in your posts.

prajakta

  • Regular Member
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: display images on word document
« Reply #2 on: January 02, 2012, 07:15:35 AM »
header("Content-type: application/vnd.ms-word");
         header("Content-Disposition: attachment;Filename=shortlisedpics.doc");


add this in the end part of yr code...

jSherz

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 409
  • Karma: +4/-0
    • View Profile
    • jSherz.com
Re: display images on word document
« Reply #3 on: January 02, 2012, 07:27:20 AM »
Use HTML image tags:

PHP Code: [Select]
<img src="http://your-site.com/some-image.jpg" alt="Some Image">
Looking for PHP tutorials? View mine. Please use code or PHP tags in your posts.

prajakta

  • Regular Member
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: display images on word document
« Reply #4 on: January 02, 2012, 08:33:11 AM »
i tried this already..bt it is displaying a cross mark instead of image

jSherz

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 409
  • Karma: +4/-0
    • View Profile
    • jSherz.com
Re: display images on word document
« Reply #5 on: January 02, 2012, 08:35:38 AM »
Have you got the image uploaded on your site and are you using a publicly accessible, full URL?

e.g:

Code: [Select]
http//www.some-site.com/image.jpg
Rather than:

Code: [Select]
/image.jpg
Looking for PHP tutorials? View mine. Please use code or PHP tags in your posts.

prajakta

  • Regular Member
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: display images on word document
« Reply #6 on: January 03, 2012, 05:54:08 AM »
there is no such url for my image.....query get executed for showing images one by one...thats m giving only path for images

jSherz

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 409
  • Karma: +4/-0
    • View Profile
    • jSherz.com
Re: display images on word document
« Reply #7 on: January 03, 2012, 05:57:01 AM »
there is no such url for my image.....query get executed for showing images one by one...thats m giving only path for images

What do you mean? Could you post what format the image src is in?
Looking for PHP tutorials? View mine. Please use code or PHP tags in your posts.

prajakta

  • Regular Member
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: display images on word document
« Reply #8 on: January 04, 2012, 03:23:12 AM »
this is part of my code...i did it as you suggest and the image whose path i specified displayed properly also...but the thing is how yo display all photos as m using for loop....cz it is not related to one image...here is my part of the code...pls do needful...its very urgent

PHP Code: [Select]
while ($row=mysql_fetch_array($result))
	
	
{
$regid=$row[0];
	
	
$blow=$row[1];
	
	


if(
$regid)
	
 {
$objectIndex "PHT";
	
$whereclause " WHERE RegID=".$regid
	
$otherclause "";
	
$fields "PhotoID, BlowUp, DisplayType, RegID";
	
//$result_array = _getRows($objectIndex, $fields, $whereclause, $otherclause);
	
	
	

	
$result_array="select ".$fields"from" .$objectIndex."where" .$whereclause;
 
$blowup_indx 1;
 
$regid_indx 3;
   
for(
$i=0;$i<count($result_array);$i++)
	
   {
	



	
$photo="<img src='" _getBaseUrl() . "/photographs/" $result_array[$i][$blowup_indx] . "' border=1 width=100 height=100>";
	
   
	
$str.="<tr><td>$regid</td><td>$photo</td></tr>";
	
   
	
	
}}}
« Last Edit: January 06, 2012, 09:15:19 AM by jSherz »

prajakta

  • Regular Member
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: display images on word document
« Reply #9 on: January 04, 2012, 05:22:53 AM »
this is part of my code...i did it as you suggest and the image whose path i specified displayed properly also...but the thing is how yo display all photos as m using for loop....cz it is not related to one image...here is my part of the code...pls do needful...its very urgent

while ($row=mysql_fetch_array($result))
      {$regid=$row[0];
      $blow=$row[1];
      

if($regid)
    {
$objectIndex = "PHT";
   $whereclause = " WHERE RegID=".$regid;
   $otherclause = "";
   $fields = "PhotoID, BlowUp, DisplayType, RegID";
   //$result_array = _getRows($objectIndex, $fields, $whereclause, $otherclause);
         
   $result_array="select ".$fields. "from" .$objectIndex."where" .$whereclause;
 $blowup_indx = 1;
 $regid_indx = 3;
   
for($i=0;$i<count($result_array);$i++)
      {
   


   $photo="<img src='" http://192.168.0.2/site/inmatch"/photographs/" . $result_array[$i][$blowup_indx] . "' border=1 width=100 height=100>";
      
   $str.="<tr><td>$regid</td><td>$photo</td></tr>";
      
      }}}

jSherz

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 409
  • Karma: +4/-0
    • View Profile
    • jSherz.com
Re: display images on word document
« Reply #10 on: January 04, 2012, 11:07:40 AM »
At a glance, that code looks fine to me. Could you temporarily remove the word document header part and send the output that your script generates?
Looking for PHP tutorials? View mine. Please use code or PHP tags in your posts.

prajakta

  • Regular Member
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: display images on word document
« Reply #11 on: January 05, 2012, 12:34:45 AM »
it is displaying the same output on webpage but on word document it was showing cross mark instead of image...n on web page it is just creating a box of specified height and width bt nt showing image
my path is ryt as i have used the same in many other applications

jSherz

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 409
  • Karma: +4/-0
    • View Profile
    • jSherz.com
Re: display images on word document
« Reply #12 on: January 05, 2012, 02:47:43 AM »
Unless some sort of anti-hotlinking or other website copying protection is preventing the server from displaying the images, something must be wrong with the paths.

Can you post back with the view-source of that page?
Looking for PHP tutorials? View mine. Please use code or PHP tags in your posts.

prajakta

  • Regular Member
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: display images on word document
« Reply #13 on: January 05, 2012, 04:37:05 AM »
this is the source code of output page...
<table width='50%' border='1' align='center'><tr><td>RegID</td><td>Photo</td></tr><tr><td>15039</td><td><img src="../photographs/$result_array[$i][$blowup_indx] " border=1 width=200 height=200></td></tr><tr><td>15039</td><td><img src="../photographs/$result_array[$i][$blowup_indx] " border=1 width=200 height=200></td></tr><tr><td>15027</td><td><img src="../photographs/$result_array[$i][$blowup_indx] " border=1 width=200 height=200></td></tr><tr><td>15027</td><td><img src="../photographs/$result_array[$i][$blowup_indx] " border=1 width=200 height=200></td></tr></table>




have any other solution????

prajakta

  • Regular Member
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: display images on word document
« Reply #14 on: January 06, 2012, 04:33:10 AM »
jSherz pls give me some solution....m fed up now....