View Full Version : Calling javascript function in php

07-19-2008, 03:21 AM

I have a page where you can upload files from your computer or from a url.

In file_upload.php I have 2 forms and a javascript function.

One submits to upload_from_computer.php using an iframe for an ajax-like upload:

<form name="upload_from_computer" action="edit/upload_from_computer.php?page_id=<? echo $page_id; ?>" method="post" enctype="multipart/form-data" target="upload_target">...and so on

The other submits to upload_from_url.php

<form name="upload_from_url" ENCTYPE="multipart/form-data" action="edit/upload_from_url.php?page_id=<? echo $page_id; ?>" method="post">...and so on

The javascript function is:

<script type="text/javascript">
function done_uploading() {

When the upload_from_computer.php is done I use:

<script language="javascript" type="text/javascript">window.top.window.done_uploading();</script>

But if I put this in upload_from_url.php I get an error in firefox:

Error: window.top.window.stopUpload is not a function
Line: 1

I think it works for upload_from_computer because of the iframe, and window.top.window selects the correct page.

Anyone know how to call stopUpload() from upload_from_url.php?


07-20-2008, 09:17 AM
We'd have to see much more of the code and how it's all working together to have any idea what could be going on.

07-20-2008, 05:46 PM
Thanks...Actually, I figured something out. This is really a job for an ajax call. The script I was using to upload from the computer can simply call a javascript function in another file using window.top.window (I guess because of the iframe). But, uploading from a website I just need an ajax call to send a string to a php file (the url).