Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wait for action? 2

Status
Not open for further replies.

dle46163

IS-IT--Management
Jul 9, 2004
81
US
Any ideas about this would be great...I'm running a for loop that uploads some files through a POST form. During the loop I check to see if a file with that name already exists. No problem so far....If I find a name match, I want to interrupt the loop with a prompt that says there is a conflict and asks the user if they want to overwrite the file or skip it. Upon selection, I need the for loop to continue. Should this be a javascript thing? If so I need to pass a "flag" from the javascript to PHP so I can deal with the users selection accordingly. ANyone have thoughts on the best way to accomplish this?
 
You need to understand that PHP runs on the server and Javascript and all client interactions occur when PHP script already finished. So, what you want would not be achievable like you want it. You would need to make a test harness saying something like (in pseudo code)
Code:
if ((overwrite file is no) and (file exists))
{
   display page asking if overwrite and resubmit
}
The overwrite flag would be something that is off by default but could be turned on on that extra page and resubmitted to the form. Hope it makes some sense.
 
as Vragabond says - javascript for user interaction. you might consider using an ajax/sajax methodology for keeping state with the user and the server at the same time. pear has an ajax class in beta at the moment that might help you on your way.
 
I came up with an idea...not the best but it works...On the form page I created a check box that basically says OVERWRITE files with same name. If that's checked everything works as normal...If unchecked it simply skips the upload for any file with the same name and kicks out an appropriate alert when uploads are complete. So user input is made before the upload starts instead of during.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top