By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,721 Members | 1,206 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,721 IT Pros & Developers. It's quick & easy.

How do you write this Javascript in PHP?

P: n/a
Don
How do I code the following Javascript to run in a PHP script?

-------------------------
<script type="text/javascript" language="javascript">
//
function passfile1path()
{
var path = document.processPictures.userfile1.value;
document.processPictures.file1path.value = path;
}
</script>

<form...>
<input type=file name="userfile1" onfocus="passfile1path();" size=90 maxlength=2000000
accept="image/jpeg" tabindex=1>

<input type=hidden name=file1path>
</form>
-------------------------
Just when I think I'm getting to know a little bit about PHP, I run into another stumbling block.
Thanks for your help.
Don
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Don wrote:
How do I code the following Javascript to run in a PHP script?

-------------------------
<script type="text/javascript" language="javascript">
//
function passfile1path()
{
var path = document.processPictures.userfile1.value;
document.processPictures.file1path.value = path;
}
</script>

<form...>
<input type=file name="userfile1" onfocus="passfile1path();" size=90
maxlength=2000000 accept="image/jpeg" tabindex=1>

<input type=hidden name=file1path>
</form>
-------------------------


You can't do that in PHP. Javascript is a client based programming language
and your code example is responding to events triggered in the client. PHP
runs on the server.

I'm a little confused why you need to assign the value of the "userfile1"
file box to a hidden variable anyway, as the $_FILE array in PHP will be
populated with everything you need.

Refer to the manual at http://www.php.net/features.file-upload for more
information about how to handle file uploads.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #2

P: n/a
Don wrote:
How do I code the following Javascript to run in a PHP script?

-------------------------
<script type="text/javascript" language="javascript">
//
function passfile1path()
{
var path = document.processPictures.userfile1.value;
document.processPictures.file1path.value = path;
}
</script>

<form...>
<input type=file name="userfile1" onfocus="passfile1path();" size=90 maxlength=2000000
accept="image/jpeg" tabindex=1>

<input type=hidden name=file1path>
</form>

You don't. That javascript performs a client side operation. PHP only
works on the server side.
Jul 17 '05 #3

P: n/a
2metre <2m****@xxxhersham.net> wrote in message news:<cl**********@hercules.btinternet.com>...
Don wrote:
How do I code the following Javascript to run in a PHP script?

-------------------------
<script type="text/javascript" language="javascript">
//
function passfile1path()
{
var path = document.processPictures.userfile1.value;
document.processPictures.file1path.value = path;
}
</script>

<form...>
<input type=file name="userfile1" onfocus="passfile1path();" size=90 maxlength=2000000
accept="image/jpeg" tabindex=1>

<input type=hidden name=file1path>
</form>

You don't. That javascript performs a client side operation. PHP only
works on the server side.


could echo it out, if just wanted it in the code
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.