php - File submission worked until I added jQuery, whats the issue? -


i having strange issue able submit files , upload them, have added bit of jquery within head of webpage, doesn't seem work anymore:

i tested once again without jquery , works fine, jquery messing somewhere. anyway can accomplish same objective, differently?

jquery:

$(document).ready(function() {     var options = $('select[name=itemtype]');     var optionval = options.val();     var filer = $('input[name=itemfile');     var filerval = $('input[name=itemfile]').val();      options.change(function() {         optionval = $(this).val();          if(optionval == 1 || optionval == 3) {             $('input[name=itemcontact]').removeattr('disabled');             $('input[name=itemcontact]').attr('required','true');         } else {             $('input[name=itemcontact]').attr('disabled','true');             $('input[name=itemcontact]').removeattr('required');         };         if(optionval != 5) {             $('input[name=itemfile]').removeattr('disabled');             $('span.inputfile').css("display","block");         } else {             $('input[name=itemfile]').attr('disabled','true');             $('span.inputfile').css("display","none");         };     });     filer.change(function() {         filerval = $(this).val();         $(this).parent().text(filerval);     }); }); 

html form:

note: $sectionname defined earlier throughout webpage, , work.

<form class="col-12" method="post" action="./action.php?upload" enctype="multipart/form-data">     <p class="head">upload <i><?php echo $sectionname; ?></i></p>     <div class="con">         <input name="sectionid" type="hidden" value="<?php echo $section; ?>" required />         <select name="itemtype" required>             <option selected disabled>select item type</option>             <option value="1">downloadable, contact</option>             <option value="2">downloadable</option>             <option value="3">installable, contact</option>             <option value="4">installable</option>             <option value="5">browsable</option>         </select>         <span class="inputfile" style="display:none;">             select file             <input name="itemfile" type="file" required />         </span>         <input name="itemname" type="text" placeholder="enter item name" required />         <input name="itemcontact" type="email" placeholder="enter contact email address" disabled />         <button type="submit">submit</button>     </div> </form> 

action.php?upload:

$filedir = "./uploads/"; $filename = preg_replace("/[^a-z0-9._-]/i", "_", $_files['itemfile']["name"]); $itemdir = $filedir. $filename; $sectionid = $_post['sectionid']; $itemname = $_post['itemname']; $itemtype = $_post['itemtype']; $itemcontact = $_post['itemcontact'];  if (file_exists($itemdir)) {     echo '<p class="alert">sorry, file exists</p>'; } else {     if (move_uploaded_file($_files["itemfile"]["tmp_name"], $itemdir)) {         mysqli_report(mysqli_report_error | mysqli_report_strict);         if($createitem = $con->prepare("insert items(sectionid,itemname,itemtype,itemdir) values(?,?,?,?)")) {             $createitem->bind_param("isis", $sectionid,$itemname,$itemtype,$itemdir);             if($createitem->execute()) {                 $itemid = $createitem->insert_id;                 if($itemtype == 1 || $itemtype == 3) {                     if($createcontact = $con->prepare("insert contacts(itemid,itemcontact) values(?,?)")) {                         $createcontact->bind_param("is", $itemid,$itemcontact);                         if($createcontact->execute()) {                             echo '<p class="alert">item created</p>';                         } else {                             echo "<p class=alert'>execute failed: [createcontact] (" . $createcontact->errno . ") " . $createcontact->error. '</p>';                         };                     } else {                         echo '<p class="alert">item created</p>';                     };                     $createcontact->close();                 };             };         };         $createitem->close();     }; }; 

rather uploading file, or storing in $_files doesn't passed action.php. have checked $_post , $_files, doesn't show in either, whereas before did.

note: internal website on 1 of web servers, doesn't matter if vulnerable sql injection.

selector not valid @ line

var filer = $('input[name=itemfile'); 

var filer = $('input[name=itemfile ] ');


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -