| | |
problem with image submit button
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2009
Posts: 17
Reputation:
Solved Threads: 0
hi friends,
I already have a code that upload image with re size it.
and its working fine.
but i have a problem when i use
<input type ="image" src="myfile.jpeg" name="submit" value="Submit">
in the position of
<input type="submit" name="submit" value="Submit">
image upload cannot act.i cant understand what is the problem and how to resolve it????
plz help me.
I already have a code that upload image with re size it.
PHP Syntax (Toggle Plain Text)
<form action="<?php echo $_server['php-self']; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm"> <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" /> <input type="submit" name="submit" value="Submit"><p> </form> <?php if(isset($_POST['submit'])){ if (isset ($_FILES['new_image'])){ $imagename = $_FILES['new_image']['name']; $source = $_FILES['new_image']['tmp_name']; $target = "images/".$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "images/" . $imagepath; //This is the new file you saving $file = "images/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 150; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; echo "Large image: <img src='images/".$imagepath."'><br>"; } } ?>
and its working fine.
but i have a problem when i use
<input type ="image" src="myfile.jpeg" name="submit" value="Submit">
in the position of
<input type="submit" name="submit" value="Submit">
image upload cannot act.i cant understand what is the problem and how to resolve it????
plz help me.
0
#2 Nov 9th, 2009
Thats simply because of this line..
when u use an image for input, it doesnt post values as "name"="value" as it does in case of buttons..
instead it will post name_x=... and name_y=... where the values are the x & y coordinates of the point where user clicks the image..
modify ur code to hope this helps..
cheers!!!
PHP Syntax (Toggle Plain Text)
if(isset($_POST['submit'])){
when u use an image for input, it doesnt post values as "name"="value" as it does in case of buttons..
instead it will post name_x=... and name_y=... where the values are the x & y coordinates of the point where user clicks the image..
modify ur code to
PHP Syntax (Toggle Plain Text)
if(isset($_POST['submit_x'] && isset($_POST['submit_y'])){ // rest remains the same
cheers!!!
•
•
•
•
hi friends,
I already have a code that upload image with re size it.
PHP Syntax (Toggle Plain Text)
<form action="<?php echo $_server['php-self']; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm"> <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" /> <input type="submit" name="submit" value="Submit"><p> </form> <?php if(isset($_POST['submit'])){ if (isset ($_FILES['new_image'])){ $imagename = $_FILES['new_image']['name']; $source = $_FILES['new_image']['tmp_name']; $target = "images/".$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "images/" . $imagepath; //This is the new file you saving $file = "images/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 150; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; echo "Large image: <img src='images/".$imagepath."'><br>"; } } ?>
and its working fine.
but i have a problem when i use
<input type ="image" src="myfile.jpeg" name="submit" value="Submit">
in the position of
<input type="submit" name="submit" value="Submit">
image upload cannot act.i cant understand what is the problem and how to resolve it????
plz help me.
Gimme reputation points if u find my post helpful.
use [code] tags wherever applicable
dont start a new thread unless u cant find the topic already on forum.
mark a thread "solved" as soon as u get a solution
use [code] tags wherever applicable
dont start a new thread unless u cant find the topic already on forum.
mark a thread "solved" as soon as u get a solution
•
•
Join Date: Sep 2009
Posts: 557
Reputation:
Solved Threads: 64
0
#3 Nov 9th, 2009
when you using use instead of -
PHP Syntax (Toggle Plain Text)
<input type ="image" src="myfile.jpeg" name="submit" value="Submit">
PHP Syntax (Toggle Plain Text)
if(isset($_POST['submit_x']) && $_POST['submit_x'] !='' ){
PHP Syntax (Toggle Plain Text)
if(isset($_POST['submit_x'])){
"The discipline of writing something down is the first step towards making it happen."
follow me on twitter
follow me on twitter
0
#4 Nov 9th, 2009
Hey.
It's a LOT more stable to just do:
You should never actually test to see if the submit button was sent, because there are cases where the button is left out. For instance, if you submit the form by pressing the Enter button, certain browsers do not include the submit button.
It's best to always test a data field, or add a hidden field specifically for that purpose.
It's a LOT more stable to just do:
html Syntax (Toggle Plain Text)
<form action="script.php" method="post"> <input type="hidden" name="isSubmitted" value="1"> <input type="image" src="myfile.jpeg" name="submit" value="Submit"> </form>
php Syntax (Toggle Plain Text)
<?php if(isset($_POST['isSubmitted'])) { // etc... } ?>
You should never actually test to see if the submit button was sent, because there are cases where the button is left out. For instance, if you submit the form by pressing the Enter button, certain browsers do not include the submit button.
It's best to always test a data field, or add a hidden field specifically for that purpose.
Last edited by Atli; Nov 9th, 2009 at 4:30 pm.
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
And use [code] tags!
0
#5 Nov 10th, 2009
woooo... had no idea abt that submit button being missed out... nice info...
cheers !!!
cheers !!!
•
•
•
•
Hey.
It's a LOT more stable to just do:
html Syntax (Toggle Plain Text)
<form action="script.php" method="post"> <input type="hidden" name="isSubmitted" value="1"> <input type="image" src="myfile.jpeg" name="submit" value="Submit"> </form>php Syntax (Toggle Plain Text)
<?php if(isset($_POST['isSubmitted'])) { // etc... } ?>
You should never actually test to see if the submit button was sent, because there are cases where the button is left out. For instance, if you submit the form by pressing the Enter button, certain browsers do not include the submit button.
It's best to always test a data field, or add a hidden field specifically for that purpose.
Gimme reputation points if u find my post helpful.
use [code] tags wherever applicable
dont start a new thread unless u cant find the topic already on forum.
mark a thread "solved" as soon as u get a solution
use [code] tags wherever applicable
dont start a new thread unless u cant find the topic already on forum.
mark a thread "solved" as soon as u get a solution
![]() |
Similar Threads
- convert submit button of php array into image button (PHP)
- Php submit button problem.. (PHP)
- help adding a 2nd Browse box & 2nd SUBMIT button (ASP)
- Automate undisabled a “submit button”? (ColdFusion)
- submit button (PHP)
- how to get 1 submit button to validate user's choice (ASP)
- email sending from a jsp page after submit button (JSP)
- Submit Button Coding (HTML and CSS)
- Question about html form image submit value (HTML and CSS)
Other Threads in the PHP Forum
- Previous Thread: Newbie question: PHP form not writing to MySQL database
- Next Thread: php classes
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email encode error fcc file files folder form forms function functions google howtowriteathesis href htaccess html image include insert integration ip java javascript joomla limit link login loop mail menu methods mlm mod_rewrite multiple multipletables mysql oop open parse paypal pdf php problem provider query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table template tutorial update upload url validation validator variable video web xml youtube





