FORUMS: list search recent posts

Passing a JavaScript string into SSI

COW Forums : Web Design

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Marco Solorio
Passing a JavaScript string into SSI
on Nov 16, 2006 at 4:48:39 am

So I need a dynamically generated way to display the date (and file size) of video files. The easy way is to use SSI...

File Size=<!--#flastmod file="foo.mov" -->

However, the actual file name needs to be dynamically generated since it's being spawned by tables. So I need to pass a string as the file include. So I need it to be something like this...

function spawnText(fileName) {
document.write('File Size=<!--#flastmod file="' +fileName+ '" -->');
}


But that obviously doesn't work. The server barfs it up as an error. I also tried something along these lines...

function spawnText(fileName) {
var fileString = '<!--' + '#flastmod file="' +fileName+ '" -->';
document.write('File Size=' + fileString);
}


But that doesn't work either (note that as a precaution I broke appart the string for the SSI's first token between the "<!--" and the "#flastmod" in hopes that it wouldn't start the SSI there, but not even that helped).

Now it doesn't have to be SSI (in fact I'd prefer everything to be JavaScript) but from what I gather, JS doesn't allow for getting file dates and sizes. True? And I don't know PHP.

Any ideas?

Marco Solorio  |  OneRiver Media


Return to posts index

Curtis Thompson
Re: Passing a JavaScript string into SSI
on Nov 16, 2006 at 6:21:32 am

hello marco...

ya - javascript can't read files in that sense. there are activex ways to do this, but i wouldn't rely on those for a variety of security reasons. but here would be an activex way:

http://www.thescripts.com/forum/thread460516.html

there are a few other suggestions there as well, but none are really practical....

it's a super-easy thing to do in php if you have that option:

http://php.net/filesize

now you could get really fancy with a simple javascript ajax implmentation, but i think that would be overkill here and would introduce a large amount of learning on your end that you wouldn't want to undertake...

but in most ssi implementations, you can reference external files via a virtual call (although some servers disable that for security reasons), so you could perhaps create a small php or perl script that took a file name as a param and and generated a pretty file size string and then reference it via ssi:

http://httpd.apache.org/docs/2.0/mod/mod_include.html#element.include

i think that's the easiest way to go about it...

make sense?

sitruc







Return to posts index

Curtis Thompson
Re: Passing a JavaScript string into SSI
on Nov 16, 2006 at 6:30:12 am

hello...

ugh - i'm sorry. i didn't quite read your post correctly. my answer won't work for you because you need the javascript...

unless your javascript is drawing based on a value at load time? or is it drawing dynamically based on selections the user makes after the page loads? if it's the former, my thing might work because you could pass that value at load time; otherwise you need the ajax kind of thing...

sitruc


Return to posts index


Marco Solorio
Re: Passing a JavaScript string into SSI
on Nov 16, 2006 at 8:18:10 am

Yo Curtis!!!

Nice to hear from ya, bro! Thanks for the reply. Yeah, the values are created at run time when the page loads up. Thanks for the links you provided, especially the PHP one. Since I first posted this thread, I've been looking into the PHP route. I've found a lot of info on it and I think I might try to go that route. I discovered that PHP can even look at the files in the directory and gather the file names that way which would be really cool since I then wouldn't even need to do the JavaScript string method. I've been avoiding PHP for years, but I don't know why. Seems like it shouldn't take too long to adapt.

BTW, what's a good way to view PHP files locally without having to actually upload them to the server? Kind of a dumb question but is there a plugin I can install so my browsers displays PHP as it should?

Marco Solorio  |  OneRiver Media


Return to posts index

Curtis Thompson
Re: Passing a JavaScript string into SSI
on Nov 16, 2006 at 8:31:07 am

hello...

if you mean run it as it would run on the server then the only real option is to install apache and php on your local box and run it as a webserver - pretty easy but if i'm reading you correct then that's what your path would be...

and ya - php is a nice language. you can use it in conjunction with your ssi or as a standalone - the latter is naturally easier, but the former would keep you going on your current path w/o a lot of new dev work on your site...

lemme know if you need any assistance on this!

sitruc


Return to posts index

Marco Solorio
Re: Passing a JavaScript string into SSI
on Nov 16, 2006 at 11:46:26 pm

Thanks Curtis. Your help is greatly appreciated as always. I'm really determined to get this working in PHP after much thought. It'll really do exactly what I want in the end.

And hey, are you still in the area? If so, we should go grab lunch again some time. It's been a long while... we should catch up!

Take care,

Marco Solorio  |  OneRiver Media


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]