Tuesday 15 September 2015

javascript - jquery not runnning php -



javascript - jquery not runnning php -

so i've found code allows me upload photos using using $_files

<head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css"> <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script> </head> <form class="topmenu" action="upload_file.php" method="post" enctype="multipart/form-data" > <div style="display:inline-block; position:relative; top:2px;" > <input class="ui-btn" type="file" name="file" id="file"> </div> <div style="display:inline-block; position:relative; top:-10px;" data-role="controlgroup" data-type="horizontal" > <input type="submit" name="submit" value="upload"> <a href="logout.php" class="ui-btn" >logout</a> </div> </form>

and in upload_file.php

<?php ob_start(); // connect server , select databse. $link = mysqli_connect("$host", "$username", "$password", "$db_name")or die("cannot connect"); $allowedexts = array("gif", "jpeg", "jpg", "png", "jpg"); if(!empty($_files['file']['name'])) { $temp = explode(".", $_files["file"]["name"]); $extension = end($temp); if ((($_files["file"]["type"] == "image/gif") ||($_files["file"]["type"] == "image/jpeg") || ($_files["file"]["type"] == "image/jpg") || ($_files["file"]["type"] == "image/pjpeg") || ($_files["file"]["type"] == "image/x-png") || ($_files["file"]["type"] == "image/png")) && ($_files["file"]["size"] < 20000000) && in_array($extension, $allowedexts)) { if ($_files["file"]["error"] > 0) { echo "return code: " . $_files["file"]["error"] . "<br>"; } else { echo "upload: " . $_files["file"]["name"] . "<br>"; echo "type: " . $_files["file"]["type"] . "<br>"; echo "size: " . ($_files["file"]["size"] / 1024) . " kb<br>"; echo "temp file: " . $_files["file"]["tmp_name"] . "<br>"; if (file_exists("upload/" . $_files["file"]["name"])) { echo $_files["file"]["name"] . " exists. "; } else { $sql="insert $tbl_name (name, type, size) values ('" . mysqli_real_escape_string($link , $_files["file"]["name"]) . "','" . mysqli_real_escape_string($link , $_files["file"]["type"]) . "','" . mysqli_real_escape_string($link , $_files["file"]["size"]) . "')"; if (!mysqli_query($link,$sql)) { die('error: ' . mysqli_error($link)); } move_uploaded_file($_files["file"]["tmp_name"], "upload/" . $_files["file"]["name"]); echo "stored in: " . "upload/" . $_files["file"]["name"]; } header("location:main_login.php"); } } } else { if ( !empty($_server['content_length']) && empty($_files) && empty($_post) ) { echo 'the uploaded zip large. must upload file smaller ' . ini_get("upload_max_filesize"); } } ?>

but i've add together jquery mobile ui buttons here http://www.w3schools.com/jquerymobile/jquerymobile_buttons.asp , when press submit/upload, taken upload_file.php it's white screen. far can tell nil happening! if remove jquery stuff starts working again, site looks bit naff. thanks.

please turn off ajax navigation that's big part of jquery mobile. 1 time that's done, should work fine. ajax navigation on pages added dom rather navigated to. hence form submissions not work way expect them to.

ref: http://demos.jquerymobile.com/1.4.4/navigation/ http://api.jquerymobile.com/global-config/

javascript php jquery html

No comments:

Post a Comment