Tuesday 21 November 2017

javascript - using isset($_POST['upload']){ ... } and calling it on form input type file change and not the submit button

In my php page,
I have a form
as:



 
'multipart/form-data' method="post">

Select File:




type="submit" name="upload" value="Upload" />





When I
submit the form on clicking the submit 'upload', the following php is called which is on
the same php
page:



 if
(isset($_POST['upload'])) { ...Do stuff... }
?>




Now, I
dont want to use the submit in my html form and want to trigger this php whenever a file
in the input type file is selected. i.e. the form should be submitted automatically on
file selection without the submit button. Also, i want a if condition such as
isset($_POST['']) and dont want to use just a post check as $_SERVER['REQUEST_METHOD']
== 'POST'



Any help will be
appreciated.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...