473,785 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to return a file

Hello all,

In some html code I have the following:

<script type='text/javascript' src='foo.js'></script>

However, I'd like to replace 'foo.js' with something like
"bar.php?file=f oo" and have bar.php echo foo.js back to the script
element. Is this possible?

Oct 17 '06
15 1641

"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:7r******** *************** *******@comcast .com...
<snip/>
>What a confusing way to do it - when Joe's method works quite well.
what a confusing and totally uncalled for response: when argument fails
just
dismiss... oi!

what is so confusing about replacing 'foo.js' with 'script.php?foo '
after
all it is that simple, the rest is illustration padding...
and BTW in case you didn't notice Joe and I are essentailly in agreement
except for the header part, which you don't argue with, just dismiss the
entire post. Anyone can dismiss. All I have done is expand on what Joe
said
with an example but showing that it works just fine without the header.
And your contribution is...even more confusing but lacking any
substance.


No, I disagree.

Yes, your answer and Joe's do the same thing.
OK...
But his is
straightforward and easy to understand.
That's clearly _not_ the case as Bryan responded "Thanks for the help guys,
but I can't get it to work."
Yours is more complicated,
harder to understand and more prone to errors - especially when you have
to later modify it.
err...since Joe's didn't cut it , I felt that expansion might help.
and I'm very surprised that you find such a simple example as the few lines
I supplied hard to understand.
LOL The "prone to errors" assertion is interesting in such a short piece of
script...

It was meant as the simplest, yet complete, _working_ example of returning
javascipt using a PHP script.
A place to start from...
the basic minimum HTML tags around the script tag,
<html>...<scrip t...></script><html>
don't see what's so prone to error there... I must be missing something

the other the bare minimum to return some javascript:
<?php #foo.php
$js = do_what_you_do_ to_get_the_java script();
echo $js;
?>
prone to error? well I guess do_what_you_do_ to_get_the_java script(); is
prone to error but it is just as prone when done from Joe's same difference.
>
KISS. And Joe's is much simpler.
The point of the exercise is to help Bryan "get it to work"
Clearly, although simpler, Joe's post failed in that end.
Has my post failed to help Bryan get it to work? Only Bryan can say.

Just in case Bryan hasn't got it to work yet:
I'll simplify bits for Jerry and expand some more for Bryan, best of both
worlds :-)

in the html (simplified...j ust the script line from the file):
<script type='text/javascript' src='bar.php?fi le=foo'></script>

in the javascript file foo.js:
alert("hi there!");

in the PHP file, with Joe's header:
<?php #bar.php
header('Content-type: text/javascript');
echo file_get_conten ts($_GET['file'].".js");
?>

or even simpler, which Jerry professes to like :-), without Joe's header
<?php #bar.php
echo file_get_conten ts($_GET['file'].".js");
?>

This works with and without the header in bar.php
minimum 1 code line in each file. simple enough? and yet not so simple as
Joe's post but yet expanded to a working example.

Hope this helps get it to work for you Bryan.

Oct 18 '06 #11

"Rik" <lu************ @hotmail.comwro te in message
news:d0******** *************** ***@news2.tudel ft.nl...
Jerry Stuckle wrote:
KISS. And Joe's is much simpler.


Script building rule #1: the most simple solution is often the right one.

:-)
--
Rik Wasmus
'cept in this case there was no script in the "most simple solution" as
defined by Jerry and which of course for the OP wasn't a solution, so no and
no. :-)
Oct 18 '06 #12
Johnny wrote:
"Rik" <lu************ @hotmail.comwro te in message
news:d0******** *************** ***@news2.tudel ft.nl...
>>Jerry Stuckle wrote:
>>>KISS. And Joe's is much simpler.


Script building rule #1: the most simple solution is often the right one.

:-)
--
Rik Wasmus

'cept in this case there was no script in the "most simple solution" as
defined by Jerry and which of course for the OP wasn't a solution, so no and
no. :-)

No, he didn't type it out. Rather than give an answer, Joe did
something better - he have guidance on how to do it. That way the
operator has a chance to learn something.

It's exactly what I do when teaching classes. And if they continue to
have problems, I give them more detailed guidance.

But just giving them an answer on something like this doesn't give him a
chance to learn.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Oct 18 '06 #13
Rik
Jerry Stuckle wrote:
Johnny wrote:
>"Rik" <lu************ @hotmail.comwro te in message
news:d0******* *************** ****@news2.tude lft.nl...
>>Jerry Stuckle wrote:

KISS. And Joe's is much simpler.
Script building rule #1: the most simple solution is often the
right one.

'cept in this case there was no script in the "most simple solution"
as defined by Jerry and which of course for the OP wasn't a
solution, so no and no. :-)


No, he didn't type it out. Rather than give an answer, Joe did
something better - he have guidance on how to do it. That way the
operator has a chance to learn something.

It's exactly what I do when teaching classes. And if they continue to
have problems, I give them more detailed guidance.

But just giving them an answer on something like this doesn't give
him a chance to learn.
It is indeeed what people should do. Even after all this time (and my
little hiatus) I haven't learned that yet.

The problem is that it's often simpler and faster to type out a solution
then explain it, and I'm lazy offcourse :-)

(Oh: and I haven't repaired my sig-seperator for nothing, my sig does not
have to be quoted...)

--
Grtz,

Rik Wasmus
Oct 18 '06 #14
Rik wrote:
Jerry Stuckle wrote:
>>Johnny wrote:
>>>"Rik" <lu************ @hotmail.comwro te in message
news:d0***** *************** ******@news2.tu delft.nl...
Jerry Stuckle wrote:
>KISS. And Joe's is much simpler.
Script building rule #1: the most simple solution is often the
right one.
'cept in this case there was no script in the "most simple solution"
as defined by Jerry and which of course for the OP wasn't a
solution, so no and no. :-)


No, he didn't type it out. Rather than give an answer, Joe did
something better - he have guidance on how to do it. That way the
operator has a chance to learn something.

It's exactly what I do when teaching classes. And if they continue to
have problems, I give them more detailed guidance.

But just giving them an answer on something like this doesn't give
him a chance to learn.


It is indeeed what people should do. Even after all this time (and my
little hiatus) I haven't learned that yet.

The problem is that it's often simpler and faster to type out a solution
then explain it, and I'm lazy offcourse :-)

(Oh: and I haven't repaired my sig-seperator for nothing, my sig does not
have to be quoted...)
Actually, I think you do a pretty good job at it, Rik.

I should also add - when it comes to more complicated problems, often I
will supply an answer, also. Mainly because there's a point where an
example is necessary to explain what you mean.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Oct 18 '06 #15
Sorry I'm just now getting around to looking at this some more. It's
been a long week! I'll try this again and let you guys know if it
works.

Thanks again for all the help you guys have offered! Again, I'll let
you know if I get it to work for me.

Bryan

Johnny wrote:
"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:7r******** *************** *******@comcast .com...
<snip/>
>>What a confusing way to do it - when Joe's method works quite well.
>>
>
what a confusing and totally uncalled for response: when argument fails
just
dismiss... oi!
>
what is so confusing about replacing 'foo.js' with 'script.php?foo '
after
all it is that simple, the rest is illustration padding...
and BTW in case you didn't notice Joe and I are essentailly in agreement
except for the header part, which you don't argue with, just dismiss the
entire post. Anyone can dismiss. All I have done is expand on what Joe
said
with an example but showing that it works just fine without the header.
And your contribution is...even more confusing but lacking any
substance.
>
>
>
No, I disagree.

Yes, your answer and Joe's do the same thing.
OK...
But his is
straightforward and easy to understand.

That's clearly _not_ the case as Bryan responded "Thanks for the help guys,
but I can't get it to work."
Yours is more complicated,
harder to understand and more prone to errors - especially when you have
to later modify it.

err...since Joe's didn't cut it , I felt that expansion might help.
and I'm very surprised that you find such a simple example as the few lines
I supplied hard to understand.
LOL The "prone to errors" assertion is interesting in such a short piece of
script...

It was meant as the simplest, yet complete, _working_ example of returning
javascipt using a PHP script.
A place to start from...
the basic minimum HTML tags around the script tag,
<html>...<scrip t...></script><html>
don't see what's so prone to error there... I must be missing something

the other the bare minimum to return some javascript:
<?php #foo.php
$js = do_what_you_do_ to_get_the_java script();
echo $js;
?>
prone to error? well I guess do_what_you_do_ to_get_the_java script(); is
prone to error but it is just as prone when done from Joe's same difference.

KISS. And Joe's is much simpler.
The point of the exercise is to help Bryan "get it to work"
Clearly, although simpler, Joe's post failed in that end.
Has my post failed to help Bryan get it to work? Only Bryan can say.

Just in case Bryan hasn't got it to work yet:
I'll simplify bits for Jerry and expand some more for Bryan, best of both
worlds :-)

in the html (simplified...j ust the script line from the file):
<script type='text/javascript' src='bar.php?fi le=foo'></script>

in the javascript file foo.js:
alert("hi there!");

in the PHP file, with Joe's header:
<?php #bar.php
header('Content-type: text/javascript');
echo file_get_conten ts($_GET['file'].".js");
?>

or even simpler, which Jerry professes to like :-), without Joe's header
<?php #bar.php
echo file_get_conten ts($_GET['file'].".js");
?>

This works with and without the header in bar.php
minimum 1 code line in each file. simple enough? and yet not so simple as
Joe's post but yet expanded to a working example.

Hope this helps get it to work for you Bryan.
Oct 22 '06 #16

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

Similar topics

8
3994
by: Paul | last post by:
Hi, Does anyone know how I would be able to drag a single file onto my applications icon and have it run some predefined code. What I want is to drop an .mp3 file onto my applications icon (not the apps form) and perform the necessary actions then give a confirmation when these actions are done then quit.
13
3797
by: J. Campbell | last post by:
I'm wanting to output a text header file in front of the data portion of an output file. However when I use "\n" or "endl" as end of line, it just puts a 0x0a in the file(which is non-printing)...in Windows you need the (0x0d 0x0a) pair, if you want a new-line in a text editor. What's the correct way to get this 2-byte sequence into a file? Thanks #include <iostream>
12
2334
by: Mike Brashars | last post by:
Hi all, I have been searching for a week and am unable to find and example to "Populate picklist from directory and return file name". I have a php script that reads a log file and plots a graph. Right now, the log name is hard coded. The logs are archived each day in the form of say ddmmyy.log and I would like to put a drop down list in the script that would allow my script to run off the "log" picked or default to the current "hard...
6
10255
by: Clint Stowers | last post by:
Using Acc2k Can anyone suggest some sample code for returning the date of a Linked File? I am linking MyFile.xls as tblMyFile. Simply put, somewhere on a form I would like to the date of the xls file. Any suggestion appreciated. Thanks in advance
9
10615
by: AP | last post by:
Is there anyway to determine what the modified or create date is for a file? In my example I am uploading a text file using the following to select the filename: GetOpenFileName Lib "COMDLG32.DLL". Is there anyway to point to that file and return the information about the file properties? Size, date modified, created, etc? Thanks
4
2296
by: tasahmed | last post by:
Hello Friends, I wrote a function which scans the current working directory and lists out details such as directory/file owner, permission etc. The output of this script can be viewing in the monitor when I give the command print_r which is printed out in a array format. The problem I facing is I want this output in a text file, but I have tried so many things it is not working I am copying my code below, I need help in this urgently....
75
3559
by: ume$h | last post by:
/* I wrote the following program to calculate no. of 'a' in the file c:/1.txt but it fails to give appropriate result. What is wrong with it? */ #include"stdio.h" int main(void) { FILE *f; char ch; long int a=0;
1
5608
by: shyaminf | last post by:
hi everybody! iam facing a problem with the transfer of file using servlet programming. i have a code for uploading a file. but i'm unable to execute it using tomcat5.5 server. kindly help me how to execute it using tomcat server5.5. the code is as follows. if you have any other coding regarding this, please send me.it's urgent. import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*;
1
1818
by: yanni127 | last post by:
hi everyone I've got a file : fstream in ("f.in"); after searching, file pointer is at the end of file and I wanna return it to the begginnig for other tasks. what statement can I use?
3
5881
by: paleman | last post by:
Hi. I'm trying to write my own version of opendir function on Windows XP.Within that function I'm calling open function: fd = open(path, O_RDONLY, 0); and this fails when path points to a directory. Does anyone know how to open a directory on Win OS so it returns a file descriptor to it.Maybe open should be given another parameters or some other function exists that I don't know of.
0
9646
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9484
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10157
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8983
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7505
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.