Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URL Variables and Windows XP

Status
Not open for further replies.

GBrigden

Programmer
Jun 24, 2002
4
GB
Hi,
As a new user of PHP, I have hit a problem. I am trting to call a PHP from my .js file. Using the getURL statement, I am passing 3 params to the .php but the .php is ignoring them. Is there something I am missing, possibly in the set-up.

TIA,

Gary
 
How .. any chance of some code please?

Different methods for different solutions and vice versa. ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Sorry......the js looks like this
'
this.url = url;
var params = [
"file="+this.file,
"start="+start,
"length="+length
];
getURL(this.url + "?" + params.join("&"), this);'

and the php like this.....

'#
# This is a simple attempt to prevent the download of just
# any file on our server
#
if ( eregi("\.svg$", $file) ) {
#
# It's an SVG file so get the file's size
#
$size = filesize($file);

if ( $start == -1 ) {.........'

I get an error when the php comes across the $file and $start, both of which are passed by the getURL....

Thanks again.
 
try using $_GET[file] and $_GET[start] in your php. ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Thanks for the help...
I have now set the code to......
'#
# This is a simple attempt to prevent the download of just
# any file on our server
#
if ( eregi("\.svg$", $_GET[file] )) {
#
# It's an SVG file so get the file's size
#
$size = filesize($_GET[file]);

if ( $_GET[start] == -1 ) {

#
# -1 is used to specify that the calling routing
# wants to know the size of the file that is
# being downloaded. Tell 'em how big it is.
#
print $size;.....'

but get an 'use of undefined constant file - assumed file' and 'use of undefined constant start - assumed start' .

 
Is your php.ini register_globals variable set to "On" ? It could help...

Ced.
 
Thanks for the response....I have checked the ini file and the variable is On, but still getting same error...

Here is the code in full:

<?
set_magic_quotes_runtime(0);

#
# This is a simple attempt to prevent the download of just
# any file on our server
#
if ( eregi(&quot;\.svg$&quot;, $_GET[file] )) {
#
# It's an SVG file so get the file's size
#
$size = filesize($_GET[file]);

if ( $_GET[start] == -1 ) {

#
# -1 is used to specify that the calling routing
# wants to know the size of the file that is
# being downloaded. Tell 'em how big it is.
#
print $size;

} elseif ( $_GET[start] < $size ) {

#
# Otherwise we are being asked for a chunk of the
# file
#
if ( ( $_GET[start] + $_GET[length] ) > $size ) {

#
# Oops. Asked for too many bytes from the
# current position. Re-adjust to how much we
# really need to read.
#
$size = $size - $_GET[start];

}

#
# Open the file for reading.
# Really should be error checking from here
# on down.
#
$fh = fopen($_GET[file], &quot;r&quot;);

#
# Move to the position where we should begin
# reading
#
fseek($fh, $_GET[start]);

#
# Read the requested number of bytes and send
# those back to the calling routine
#
print fread($fh, $_GET[length]);

#
# All done. Close the file
#
fclose($fh);

} else {

#
# The start position in the file is passed the
# end of the file. That means we're all done.
#
print &quot;done&quot;;

}
} else {

#
# Really should return some sort of violation error here
#
print &quot;done: invalid doc type: $_GET[file], $_GET[start], $_GET[length]&quot;;

}
?>

What I am trying to achive is to load a text file bit by bit returning the text to a var in javascript and allowing me to then parsexml..Any ideas?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top