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.
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....
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' .
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("\.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;
} 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], "r"
#
# 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 "done";
}
} else {
#
# Really should return some sort of violation error here
#
print "done: invalid doc type: $_GET[file], $_GET[start], $_GET[length]";
}
?>
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?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.