8 Replies - 967 Views - Last Post: 29 February 2012 - 11:17 PM Rate Topic: -----

#1 Schmit38  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 78
  • Joined: 21-December 07

How do I get a (.PNG IMAGE) to postback from .php?

Posted 29 February 2012 - 03:55 PM

I am new to PHP and trying to learn but having trouble.
Here all i want to do is take an image from my HDD and have it
display after a user clicks the submit button.
Here is my php code.. When it executes i just get an icon
that looks like a broken Image link.. Is this because of my MIME settings?
Or is it a flaw in my code?

<?php
$url = "C:\wamp\www\FORM PROCESSING\Climate_Images\Portland Climate Summary for Year 2010.png"; 
echo "<img src='$url'>";
 ?> 



Thank you!

Is This A Good Question/Topic? 0
  • +

Replies To: How do I get a (.PNG IMAGE) to postback from .php?

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4319
  • View blog
  • Posts: 12,101
  • Joined: 18-April 07

Re: How do I get a (.PNG IMAGE) to postback from .php?

Posted 29 February 2012 - 04:41 PM

Have you actually tried that path in your browser/windows explorer to make sure it is pointing at your graphic? Secondly, you are running PHP locally on your computer right and not uploading this file to a web host?

:)
Was This Post Helpful? 0
  • +
  • -

#3 Schmit38  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 78
  • Joined: 21-December 07

Re: How do I get a (.PNG IMAGE) to postback from .php?

Posted 29 February 2012 - 04:48 PM

I am using WAMP on localhost on my Windows Vista Laptop.

I have copied the posted back code and when I create an html doc from it it posts the image just fine. So something must be wrong with my php code listed above then?


Here is the page source from the posted back html file:

<html>
	<body>	
<img src='C:\wamp\www\FORM PROCESSING\Climate_Images\Portland Climate Summary for Year 2010.png'> 
</body>
</html>

This post has been edited by Schmit38: 29 February 2012 - 04:51 PM

Was This Post Helpful? 0
  • +
  • -

#4 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,297
  • Joined: 22-October 08

Re: How do I get a (.PNG IMAGE) to postback from .php?

Posted 29 February 2012 - 05:01 PM

Maybe try renaming the Image without spaces. Hope it helps :)
Was This Post Helpful? 0
  • +
  • -

#5 Schmit38  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 78
  • Joined: 21-December 07

Re: How do I get a (.PNG IMAGE) to postback from .php?

Posted 29 February 2012 - 05:34 PM

Nope... I took all the spaces out of the path. No luck

BTW, did I mention that I suck at PHP?
Was This Post Helpful? 0
  • +
  • -

#6 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6039
  • View blog
  • Posts: 23,437
  • Joined: 23-August 08

Re: How do I get a (.PNG IMAGE) to postback from .php?

Posted 29 February 2012 - 05:35 PM

The URL should not be a Windows path, it should be the path relative to the webserver's document root, likely

<img src="/FORM PROCESSING/Climate_Images/Portland Climate Summary for Year 2010.png" />


Note the use of / rather than \ as well.

And having spaces in the file or path names is not a great idea; you will likely need to convert to the spaces in the URL to %20s so they are properly handled.

<img src="/FORM PROCESSING/Climate_Images/Portland%20Climate%20Summary%20for%20Year%202010.png" />

Was This Post Helpful? 0
  • +
  • -

#7 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,297
  • Joined: 22-October 08

Re: How do I get a (.PNG IMAGE) to postback from .php?

Posted 29 February 2012 - 05:39 PM

View PostJackOfAllTrades, on 01 March 2012 - 10:35 AM, said:

The URL should not be a Windows path, it should be the path relative to the webserver's document root, likely

<img src="/FORM PROCESSING/Climate_Images/Portland Climate Summary for Year 2010.png" />


Dammit, why didn't I pick that up :( Sorry Schmit38
Was This Post Helpful? 0
  • +
  • -

#8 Schmit38  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 78
  • Joined: 21-December 07

Re: How do I get a (.PNG IMAGE) to postback from .php?

Posted 29 February 2012 - 05:42 PM

JACK OF ALL TRADES:

THANK YOU SO MUCH!!! You just solved my problem. :bananaman:
Was This Post Helpful? 0
  • +
  • -

#9 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3490
  • View blog
  • Posts: 10,058
  • Joined: 08-June 10

Re: How do I get a (.PNG IMAGE) to postback from .php?

Posted 29 February 2012 - 11:17 PM

btw. if unsure, run your file path through urlencode() if used as URI.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1