473,320 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How do you write this Javascript in PHP?

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
3 2665
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brett Baisley | last post by:
Hello I have a block of html code that I want to run by calling a javascript function to print it. Its basically a table with menu items in it that is the same for many pages, and instead of...
2
by: Geoff Wilkins | last post by:
I am using <SCRIPT src=...> to import a Javascript routine from a remote source. I am then using some of the variables given values in the routine, in my own Javascript.. Unfortunately the...
8
by: Ben | last post by:
Hi all, Just wondering how to write (using document.write) to a table cell. I have table with 3 rows and 3 colums. I want to write from within the Javascript to say third column of a first row....
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
4
by: Prowler | last post by:
In the application we are currently building, we need to write positioning code on-the-fly, based upon the screen offset of the element in the AS/400 application which drives the Web app. The 400,...
12
by: Sean | last post by:
Hi, I have the following script: ----------------------------------------------------------------------------------- <script type="text/javaScript"> <!-- document.write('<div...
2
by: bissatch | last post by:
Hi, I am trying to use JavaScript to write a table column on a web page. The code is as follows: <html> <head> <script> function displaycount() {
9
by: sonnystarks | last post by:
I am taking a course in writing javascript and it (and all the books I have been reading) tell me that if I will use the document.write syntax, I will be able to "place text on the page." None...
3
by: =?Utf-8?B?SmFzb24gSGFydHNvZQ==?= | last post by:
I get the error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.