Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $duom=$_POST['duom'];
- if(isset($_POST['submit'])) {
- if ($_FILES[data][size] > 0) {
- $file = $_FILES[data][tmp_name];
- ini_set('auto_detect_line_endings',TRUE);
- $read = fopen($file, "r");
- try {
- $stmt =$pdo->prepare ("INSERT INTO prekes(id,katid,pavadinimas,aprasymas,kiekis,kaina,photo,sandid) VALUES (:id, :katid, :name, :description, :quantity, :price, :photo, :sandid)");
- $stmt->bindParam(':id', $id);
- $stmt->bindParam(':katid', $katid);
- $stmt->bindParam(':name', $name);
- $stmt->bindParam(':description', $description);
- $stmt->bindParam(':quantity', $quantity);
- $stmt->bindParam(':price', $price);
- $stmt->bindParam(':photo', $photo);
- $stmt->bindParam(':sandid', $sandid);
- while (($data = fgetcsv($read, 10000, ";")) !== FALSE) {
- $id = $data[0];
- $katid = $data[1];
- $name = $data[2];
- $description = $data[3];
- $quantity = $data[4];
- $price = $data[5];
- $photo = $data[6];
- $sandid = $data[7];
- $stmt->execute();
- }
- } catch (Exception $e) {
- echo "Negaliu pridėti naujo įrašo";
- $messages['error'] = $e->getMessage();
- exit;
- echo $e->getMessage();
- }
- }
- }
- ?>
- <form method="post" enctype="multipart/form-data">
- <div class="form-group">
- <label class="control-label col-md-3 col-sm-3 col-xs-12" for="duom">produktas <span class="required">*</span>
- </label>
- <div class="col-md-6 col-sm-6 col-xs-12">
- <input type="file" id="duom" name="data" required="required" class="form-control col-md-7 col-xs-12">
- </div>
- </div>
- <div class="form-group">
- <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
- <button type="submit" name="submit" class="btn btn-success">Išsaugoti</button>
- </div>
- </div>
- <script>
- // Replace the <textarea id="editor1"> with a CKEditor
- // instance, using default configuration.
- CKEDITOR.replace( 'descr' );
- </script>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement