473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

including image, js, css from private dir

hello, here is my dir structure:

/private
mainaction.php
img.jpg

/public_html
index.php

in index.php, I include mainaction.php. In mainaction.php, i want to
have
<img src='<?php insertImageHere ?>' > and have img.jpg show in
index.php. I need to do this for a .js file and a .css as well. The
js and css I could easily enough just echo it to the page. (but they
would make my page messy while I'm debugging)

the idea is to have everything in the private dir, and have multiple
sites on my server use the code and the images.

now that I type this, I realize that I could set up a central public
site for the img css js, and use absolute links...

hints, ideas, shoves in right directions appreciated,

--
thanks for your time,
juglesh

Nov 6 '05 #1
6 2153
juglesh said the following on 06/11/2005 18:28:
hello, here is my dir structure:

/private
mainaction.php
img.jpg

/public_html
index.php

in index.php, I include mainaction.php. In mainaction.php, i want to
have
<img src='<?php insertImageHere ?>' > and have img.jpg show in
index.php.


If the image file is in a private directory, it can't be accessed by the
outside world, hence it can't be seen in a browser...
--
Oli
Nov 6 '05 #2

Oli Filth wrote:
juglesh said the following on 06/11/2005 18:28:
hello, here is my dir structure:

/private
mainaction.php
img.jpg

/public_html
index.php

in index.php, I include mainaction.php. In mainaction.php, i want to
have
<img src='<?php insertImageHere ?>' > and have img.jpg show in
index.php.


If the image file is in a private directory, it can't be accessed by the
outside world, hence it can't be seen in a browser...


not directly, no, but can i do some thing with header() etc.? I tried
<img src='<?php include 'image.php' ?>' >
I got a 404

Nov 6 '05 #3
juglesh wrote:
not directly, no, but can i do some thing with header() etc.? I tried
<img src='<?php include 'image.php' ?>' >
I got a 404


That'll simply print the contents of image.php into the src='' tag. Not
what you want. Try viewing your HTML sourcecode once in a while to check
for things like this.

Cheers,
Nicholas Sherlock
Nov 7 '05 #4
juglesh (ju*********@hotmail.com) wrote:

: Oli Filth wrote:
: > juglesh said the following on 06/11/2005 18:28:
: > > hello, here is my dir structure:
: > >
: > > /private
: > > mainaction.php
: > > img.jpg
: > >
: > > /public_html
: > > index.php
: > >
: > > in index.php, I include mainaction.php. In mainaction.php, i want to
: > > have
: > > <img src='<?php insertImageHere ?>' > and have img.jpg show in
: > > index.php.
: >
: > If the image file is in a private directory, it can't be accessed by the
: > outside world, hence it can't be seen in a browser...

: not directly, no, but can i do some thing with header() etc.?

No.

The file must be in an accessible place.

You mentioned having a public directory with links to the "real" copy of
each "private" file. That technique would work.

OR - consider _copying_ the private file to the public location. That way
you can edit a private copy ahead of time and then "publish" it when ready
(by copying to the public area). That might be more secure as there would
be less that could go wrong to allow the web server to serve anything not
in the public area. ($0.10)
--

This programmer available for rent.
Nov 7 '05 #5

Malcolm Dew-Jones wrote:
juglesh (ju*********@hotmail.com) wrote:

: Oli Filth wrote:
: > juglesh said the following on 06/11/2005 18:28:
: > > hello, here is my dir structure:
: > >
: > > /private
: > > mainaction.php
: > > img.jpg
: > >
: > > /public_html
: > > index.php
: > >
: > > in index.php, I include mainaction.php. In mainaction.php, i want to
: > > have
: > > <img src='<?php insertImageHere ?>' > and have img.jpg show in
: > > index.php.
: >
: > If the image file is in a private directory, it can't be accessed by the
: > outside world, hence it can't be seen in a browser...

: not directly, no, but can i do some thing with header() etc.?

No.
or with some file_get_contents thing. For instance, you can turn an
image into a string of text and spit it out. Not sure how compatible
this is.
The file must be in an accessible place.

You mentioned having a public directory with links to the "real" copy of
each "private" file. That technique would work.


Yeah, I'm just going with serving the images and .js from a public dir.
The css I couldnt make work with FF, @import worked fine with IE. I'm
just echoing the css straight to the page now.

--
thanks all!
juglesh

Nov 8 '05 #6

juglesh wrote:
hello, here is my dir structure:

/private
mainaction.php
img.jpg

/public_html
index.php

in index.php, I include mainaction.php. In mainaction.php, i want to
have
<img src='<?php insertImageHere ?>' > and have img.jpg show in
index.php. I need to do this for a .js file and a .css as well.


Ok, this turned out to be an Apache question. You need to use an Alias
to tell apache what dir to look in, despite what the browser is asking
for. And, <Directory> to allow the access. The following code goes in
apache's httpd.conf config file, in my case, under the line that says
<IfModule mod_alias.c>

Alias /test/ "c:/my documents/_websites/guava/private/test/"

<Directory "c:/my documents/_websites/guava/private/test">
Order allow,deny
Allow from all
</Directory>

That will make it so <img src='/test/image.jpg' > gets the image from
the private dir, not from a folder in the web root. Works for .js,
..css, whatever.

--
j

Nov 25 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: TGF | last post by:
Hello, I am creating a console app. I try to link a static library by including it in the Linker-Input-Additional Dependencies field under the Project properties. Then I specify the path to...
0
by: TGF | last post by:
Hello, I am creating a console app. I try to link a static library by including it in the Linker-Input-Additional Dependencies field under the Project properties. Then I specify the path to...
0
by: JF Turcotte | last post by:
Hi I'm unsuccessfully trying to print a form's image under VB.NET. To print under .NET is a real pain in the , I find it to be complex, lenghty, confusing, upsetting and ultimately not to be...
1
by: Novice | last post by:
I'm afraid I will incur the wraith of Mr. Powell on this one - but I did read his #1 FAQ and some others and I still can't figure this out. I created this little c# app. and I have a PictureBox...
3
by: dale zhang | last post by:
Hi, I am trying to read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp The article author is using PictureBox for windows...
4
by: moondaddy | last post by:
Using vb.net I need to download image files to the client browser where they can save to disk. Below is some sample code I'm using. when I run this the File Download window in the browser says: ...
0
by: Deepak C.G via .NET 247 | last post by:
I want to dispose the image object in my child form, unless I won't dispose this object i can't delete the image file in my folder. I get this error in MDIparent form "An unhandled exception...
4
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. ...
0
by: benfly08 | last post by:
Hi, guys. I have a program to draw bar/pie chart based on the data i hard coded in it. However, my image comes with "BLACK" background color. I don't know how to fix this. The code snippet is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.