Just wondered if anyone could help with this one please :
Let's say i have a form as follows :
Basically, just a form that allows you to input a description and a file (image) URL - When you click the "Next Step" button it will pass the description text (description) and the URL (fileurl) to the next program it calls (step2code.php) - This will work just fine if the user enters a description and MANUALLY enters a URL - It will go on to run step2code.php and process the data.
<form name="mymainform" method="post" action="step2code.php">
Enter Description : <input type="text" value="" name="description" />
Enter File URL (or press upload): <input type="text" value="" name="fileurl" />
<input type="button" name="uploadbutton" onclick="DO_CODE_HERE" />
<input type="submit" name="func" value="Next Step" />
However, what I would LIKE it to do is, if someone presses the button called "uploadbutton", it allows you to choose a file from your computer and then uploads it to a predetermined directory (which will already be set in a variable) - However, After the file has uploaded I don't want the form to refresh (there is lots of other data not shown here) - I just want it to (if successfull) return the URL of the uploaded file and place it in the field "fileurl".
I could use <input type="file"> to get the local filename and then process it in step2code.php but I would like, if possible, to validate it and ensure it uploads whilst still on this page rather than doing it later and then having to return the user to the page (and fill in all the other fields again) if there is an error.
Any ideas on the easiest way to do it please?
EDIT: Just to clarify exactly what the code needs to do :