Jump to content

Upon an Upload Form's "Submit" serve two functions?


Recommended Posts

With a basic image Upload Form, like the one in the script I'm using:

<form method="POST" enctype="multipart/form-data" action="upload_avatar.php">
<input type="hidden" name="security_token" value="[var.security_token]" />
<p align="center"><font face="Arial"><input type="file" name="img_file" size="20"></font></p>
<p align="center"><font face="Arial"><input type="submit" value="Submit" name="upload"> <input type="reset" value="Reset" name="B2"></font></p>

If I add a 'Title' field, 'Description' field/box, and when the fields are populated and the image is chosen (from the pc), and then the 'Submit' button is selected, can the image get processed by one .php file, and the 'Title', 'Description" text get processed by another .php file, from a single 'Submit' button?

Is that possible?

Edited by Chrisj
Link to comment
Share on other sites

Why do you need to do that? Your one script can handle all the inputs for you.


If you need to do this thing, set some session vars and do a header to the other script. But - it seems like a needless complication of a very simple process.

Link to comment
Share on other sites

If you are asking whether or not you can process different parts of the same form using different destination script pages by setting multiple destinations and allocating different form parts to them then yes, you can, but not without implementing some client side script such as javascript.


If you have two different script pages designed to process different aspects of the form data and are loath to copy from one to another you can include the other script page in the destination script page and it will "technically" be that different php pages are processing different parts of the form.


Although I'm completely with @gingerjm on this one - there is no obvious reason to split this across multiple scripts: it's a single, simple task.

Link to comment
Share on other sites

Again - it makes no sense to separate the handling of this form amongst two scripts unless the form is huge and the bulk of it is already being handled by a previously written script.


Chris - as for your request to 'provide an example of "set some session vars and do a header to the other script"?' - uhh, you have the wrong approach to coding, and to the purpose of this forum. What good would it do you to have us write your code? You would learn nothing from that and besides - we're here to help you learn.


If you need to ask how to set session vars, you shouldn't be attempting to do what your whole post is asking about.

Link to comment
Share on other sites

No. Doing the hard work to read and LEARN something and then applying that helps you to LEARN. If you have a problem during that LEARNing process, the forum will be happy to provide the help you need to get past that LEARNing hurdle.


If you want examples then you can google to your heart's content, but reading a manual or finding a beginner's tutorial (cause that is what this is) will get you on the right track.


And if you are one of those who uses the excuse that they don't learn well from reading, then you are in the wrong business. Programming is all about reading (and comprehending) manuals.

Edited by ginerjm
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.