Afegida funcionalitat de penjada de imatges

This commit is contained in:
janmaroto 2022-03-02 18:45:02 +01:00
parent 207c0ba819
commit d69be27c72
23 changed files with 10 additions and 547 deletions

View File

@ -11,14 +11,12 @@ export class ApiService {
) { }
addCountry(data) {
// return this.http.post('./insert.php', data);
return this.http.post('http://localhost/backend/insert.php', data);
return this.http.post('http://localhost/backend/insert_old.php', data);
}
getCountries() {
return this.http.get('http://localhost/backend/read.php');
}
delCountry(countryId) {
// return this.http.post('./insert.php', data);
return this.http.post('http://localhost/backend/delete.php', countryId);
}

View File

@ -1,24 +0,0 @@
<?php
include "config.php";
$input = file_get_contents('php://input');
$data = json_decode($input, true);
$response = array();
$countryName = $data["countryName"];
$countryContinent = $data["countryContinent"];
$countryArea = $data["countryArea"];
$countryPopulation = $data["countryPopulation"];
$countryDrivingSide = $data["countryDrivingSide"];
$sqlQuery = "INSERT INTO `cs_countries` (`cs_country_id`, `cs_country_name`, `cs_country_continent`,";
$sqlQuery += " `cs_country_area`, `cs_country_population`, `cs_country_drivingSide`";
$sqlQuery += " VALUES (NULL, '$countryName', ' $countryContinent', $countryArea, $countryPopulation, '$countryDrivingSide')";
$sql = mysqli_query($con, $sqlQuery);
if($sql){
$response["message"] = "OK";
}else{
$response["message"] = "KO";
}
echo json_encode($response);
?>

View File

@ -43,7 +43,7 @@
</ion-item>
</ion-radio-group><br><br>
<ion-item>
<input type="file" [(ngModel)]="countryFlag" (change)="selectedFile($event)" />
<input type="file" [(ngModel)]="countryFlag" (change)="selectedFile($event)"/>
</ion-item>
<ion-button id="submit-button" type="button" (click)="addCountry()">Add Country</ion-button>

View File

@ -6,6 +6,7 @@ import { ApiService } from 'src/app/api.service';
templateUrl: './form.page.html',
styleUrls: ['./form.page.scss'],
})
export class FormPage implements OnInit {
constructor(
@ -21,15 +22,18 @@ export class FormPage implements OnInit {
selectedFile(event){
this.countryFlag = event.target.files[0];
console.log(this.countryFlag);
}
addCountry(){
var data = new FormData();
let data = new FormData();
data.append("countryName", this.countryName);
data.append("countryContinent", this.countryContinent);
data.append("countryArea", this.countryArea);
data.append("countryArea", this.countryPopulation);
data.append("countryPopulation", this.countryPopulation);
data.append("countryDrivingSide", this.countryDrivingSide);
data.append("countryFlag", this.countryFlag);
@ -41,6 +45,7 @@ export class FormPage implements OnInit {
// window.location.reload();
}
ngOnInit() {
}

View File

@ -16,7 +16,7 @@
</ion-item-options>
<ion-item routerLink="">
<ion-avatar slot="start">
<img src="assets/img/flags/iconfinder.com.png">
<img src="http://localhost/backend/assets/img/flags/{{country.cs_country_flag}}">
</ion-avatar>
<ion-label>
<h2>{{country.cs_country_name}}</h2>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 930 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

View File

@ -1,107 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<comment version="3.0">
<caption>World map.</caption>
<note>Front view of steel world map. Wide image.</note>
<place/>
<categories>
<category value="steel"/>
<category value="world"/>
<category value="earth"/>
<category value="continent"/>
<category value="global"/>
<category value="symbol"/>
<category value="globe"/>
<category value="international"/>
<category value="concept"/>
<category value="map"/>
<category value="africa"/>
<category value="europe"/>
<category value="america"/>
<category value="countries"/>
<category value="3d"/>
<category value="white"/>
<category value="sign"/>
<category value="icon"/>
<category value="graphic"/>
<category value="asia"/>
<category value="metallic"/>
<category value="globalization"/>
<category value="metal"/>
<category value="geography"/>
<category value="render"/>
<category value="silver"/>
<category value="planet"/>
<category value="travel"/>
<category value="middle east"/>
<category value="country"/>
<category value="shiny"/>
<category value="brushed"/>
<category value="abstract"/>
<category value="textured"/>
<category value="aluminum"/>
<category value="texture"/>
<category value="surface"/>
<category value="gray"/>
<category value="iron"/>
<category value="stainless"/>
<category value="blank"/>
<category value="polished"/>
<category value="flat"/>
<category value="abstract"/>
<category value="front view"/>
<category value="extruded"/>
<category value="bevel"/>
<category value="hard light"/>
<category value="Wide image"/>
<category value="sparse"/>
<category value="wide image"/>
<category value="map"/>
<category value="geography"/>
<category value="front view"/>
<category value="steel"/>
<category value="world"/>
<category value="earth"/>
<category value="continent"/>
<category value="global"/>
<category value="symbol"/>
<category value="globe"/>
<category value="international"/>
<category value="concept"/>
<category value="africa"/>
<category value="europe"/>
<category value="america"/>
<category value="countries"/>
<category value="3d"/>
<category value="white"/>
<category value="sign"/>
<category value="icon"/>
<category value="graphic"/>
<category value="asia"/>
<category value="metallic"/>
<category value="globalization"/>
<category value="metal"/>
<category value="render"/>
<category value="silver"/>
<category value="planet"/>
<category value="travel"/>
<category value="middle east"/>
<category value="country"/>
<category value="shiny"/>
<category value="brushed"/>
<category value="abstract"/>
<category value="textured"/>
<category value="aluminum"/>
<category value="texture"/>
<category value="surface"/>
<category value="gray"/>
<category value="iron"/>
<category value="stainless"/>
<category value="blank"/>
<category value="polished"/>
<category value="flat"/>
<category value="extruded"/>
<category value="bevel"/>
<category value="hard light"/>
<category value="sparse"/>
</categories>
</comment>

View File

@ -1,107 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<comment version="3.0">
<caption>World map.</caption>
<note>Front view of steel world map. Wide image.</note>
<place/>
<categories>
<category value="metallic"/>
<category value="wide image"/>
<category value="asia"/>
<category value="graphic"/>
<category value="icon"/>
<category value="sign"/>
<category value="white"/>
<category value="3d"/>
<category value="countries"/>
<category value="america"/>
<category value="europe"/>
<category value="africa"/>
<category value="concept"/>
<category value="international"/>
<category value="globe"/>
<category value="symbol"/>
<category value="global"/>
<category value="continent"/>
<category value="earth"/>
<category value="world"/>
<category value="steel"/>
<category value="front view"/>
<category value="geography"/>
<category value="map"/>
<category value="aluminum"/>
<category value="sparse"/>
<category value="hard light"/>
<category value="bevel"/>
<category value="extruded"/>
<category value="flat"/>
<category value="polished"/>
<category value="blank"/>
<category value="stainless"/>
<category value="iron"/>
<category value="gray"/>
<category value="surface"/>
<category value="texture"/>
<category value="globalization"/>
<category value="textured"/>
<category value="abstract"/>
<category value="brushed"/>
<category value="shiny"/>
<category value="country"/>
<category value="middle east"/>
<category value="travel"/>
<category value="planet"/>
<category value="silver"/>
<category value="render"/>
<category value="metal"/>
<category value="europe"/>
<category value="geography"/>
<category value="metal"/>
<category value="globalization"/>
<category value="metallic"/>
<category value="asia"/>
<category value="graphic"/>
<category value="icon"/>
<category value="sign"/>
<category value="white"/>
<category value="3d"/>
<category value="countries"/>
<category value="america"/>
<category value="Wide image"/>
<category value="africa"/>
<category value="map"/>
<category value="concept"/>
<category value="international"/>
<category value="globe"/>
<category value="symbol"/>
<category value="global"/>
<category value="continent"/>
<category value="earth"/>
<category value="world"/>
<category value="steel"/>
<category value="silver"/>
<category value="sparse"/>
<category value="hard light"/>
<category value="bevel"/>
<category value="extruded"/>
<category value="front view"/>
<category value="abstract"/>
<category value="flat"/>
<category value="polished"/>
<category value="blank"/>
<category value="stainless"/>
<category value="iron"/>
<category value="gray"/>
<category value="texture"/>
<category value="render"/>
<category value="planet"/>
<category value="travel"/>
<category value="middle east"/>
<category value="country"/>
<category value="shiny"/>
<category value="brushed"/>
<category value="abstract"/>
<category value="textured"/>
<category value="aluminum"/>
<category value="surface"/>
</categories>
</comment>

View File

@ -1,107 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<comment version="3.0">
<caption>World map.</caption>
<note>Front view of steel world map. Wide image.</note>
<place/>
<categories>
<category value="metallic"/>
<category value="wide image"/>
<category value="asia"/>
<category value="graphic"/>
<category value="icon"/>
<category value="sign"/>
<category value="white"/>
<category value="3d"/>
<category value="countries"/>
<category value="america"/>
<category value="europe"/>
<category value="africa"/>
<category value="concept"/>
<category value="international"/>
<category value="globe"/>
<category value="symbol"/>
<category value="global"/>
<category value="continent"/>
<category value="earth"/>
<category value="world"/>
<category value="steel"/>
<category value="front view"/>
<category value="geography"/>
<category value="map"/>
<category value="aluminum"/>
<category value="sparse"/>
<category value="hard light"/>
<category value="bevel"/>
<category value="extruded"/>
<category value="flat"/>
<category value="polished"/>
<category value="blank"/>
<category value="stainless"/>
<category value="iron"/>
<category value="gray"/>
<category value="surface"/>
<category value="texture"/>
<category value="globalization"/>
<category value="textured"/>
<category value="abstract"/>
<category value="brushed"/>
<category value="shiny"/>
<category value="country"/>
<category value="middle east"/>
<category value="travel"/>
<category value="planet"/>
<category value="silver"/>
<category value="render"/>
<category value="metal"/>
<category value="europe"/>
<category value="geography"/>
<category value="metal"/>
<category value="globalization"/>
<category value="metallic"/>
<category value="asia"/>
<category value="graphic"/>
<category value="icon"/>
<category value="sign"/>
<category value="white"/>
<category value="3d"/>
<category value="countries"/>
<category value="america"/>
<category value="Wide image"/>
<category value="africa"/>
<category value="map"/>
<category value="concept"/>
<category value="international"/>
<category value="globe"/>
<category value="symbol"/>
<category value="global"/>
<category value="continent"/>
<category value="earth"/>
<category value="world"/>
<category value="steel"/>
<category value="silver"/>
<category value="sparse"/>
<category value="hard light"/>
<category value="bevel"/>
<category value="extruded"/>
<category value="front view"/>
<category value="abstract"/>
<category value="flat"/>
<category value="polished"/>
<category value="blank"/>
<category value="stainless"/>
<category value="iron"/>
<category value="gray"/>
<category value="texture"/>
<category value="render"/>
<category value="planet"/>
<category value="travel"/>
<category value="middle east"/>
<category value="country"/>
<category value="shiny"/>
<category value="brushed"/>
<category value="abstract"/>
<category value="textured"/>
<category value="aluminum"/>
<category value="surface"/>
</categories>
</comment>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<comment version="3.0">
<caption/>
<note>world flags</note>
<place/>
<categories/>
</comment>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

View File

@ -1 +0,0 @@
<svg width="350" height="140" xmlns="http://www.w3.org/2000/svg" style="background:#f6f7f9"><g fill="none" fill-rule="evenodd"><path fill="#F04141" style="mix-blend-mode:multiply" d="M61.905-34.23l96.194 54.51-66.982 54.512L22 34.887z"/><circle fill="#10DC60" style="mix-blend-mode:multiply" cx="155.5" cy="135.5" r="57.5"/><path fill="#3880FF" style="mix-blend-mode:multiply" d="M208.538 9.513l84.417 15.392L223.93 93.93z"/><path fill="#FFCE00" style="mix-blend-mode:multiply" d="M268.625 106.557l46.332-26.75 46.332 26.75v53.5l-46.332 26.75-46.332-26.75z"/><circle fill="#7044FF" style="mix-blend-mode:multiply" cx="299.5" cy="9.5" r="38.5"/><rect fill="#11D3EA" style="mix-blend-mode:multiply" transform="rotate(-60 148.47 37.886)" x="143.372" y="-7.056" width="10.196" height="89.884" rx="5.098"/><path d="M-25.389 74.253l84.86 8.107c5.498.525 9.53 5.407 9.004 10.905a10 10 0 0 1-.057.477l-12.36 85.671a10.002 10.002 0 0 1-11.634 8.42l-86.351-15.226c-5.44-.959-9.07-6.145-8.112-11.584l13.851-78.551a10 10 0 0 1 10.799-8.219z" fill="#7044FF" style="mix-blend-mode:multiply"/><circle fill="#0CD1E8" style="mix-blend-mode:multiply" cx="273.5" cy="106.5" r="20.5"/></g></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,15 +0,0 @@
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, DELETE, PUT, PATCH, OPTIONS');
header('Access-Control-Allow-Headers: token, Content-Type');
header('Access-Control-Max-Age: 1728000');
header('Content-Length:0');
header('Content-Type: text/plain');
$host = "localhost";
$user = "country_stats";
$password = "country_stats";
$db = "country_stats";
$con = mysqli_connect($host, $user, $password, $db) or die ("could not connect to DB");
?>

View File

@ -1,73 +0,0 @@
-- phpMyAdmin SQL Dump
-- version 5.1.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Jan 19, 2022 at 08:10 PM
-- Server version: 10.5.12-MariaDB-0+deb11u1
-- PHP Version: 8.0.14
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `country_stats`
--
-- --------------------------------------------------------
--
-- Table structure for table `cs_countries`
--
CREATE TABLE `cs_countries` (
`cs_country_id` int(11) NOT NULL,
`cs_country_name` varchar(32) NOT NULL,
`cs_country_continent` varchar(16) NOT NULL,
`cs_country_area` int(32) NOT NULL,
`cs_country_population` int(32) NOT NULL,
`cs_country_drivingSide` enum('left','right') NOT NULL,
`cs_country_flag` varchar(64) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `cs_countries`
--
INSERT INTO `cs_countries` (`cs_country_id`, `cs_country_name`, `cs_country_continent`, `cs_country_area`, `cs_country_population`, `cs_country_drivingSide`, `cs_country_flag`) VALUES
(8, 'saf', 'antarctica', 243234, 24234, 'right', ''),
(11, 'adasd', 'africa', 123, 1132, 'right', ''),
(12, 'jorge', 'europe', 2, 1, 'right', '');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `cs_countries`
--
ALTER TABLE `cs_countries`
ADD PRIMARY KEY (`cs_country_id`),
ADD UNIQUE KEY `cs_country_name` (`cs_country_name`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `cs_countries`
--
ALTER TABLE `cs_countries`
MODIFY `cs_country_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

View File

@ -1,15 +0,0 @@
<?php
include "config.php";
$input = file_get_contents('php://input');
$response = array();
$sqlString = "DELETE FROM cs_countries WHERE cs_country_id = $input";
$sql = mysqli_query($con, $sqlString);
if($sql){
$response["message"] = "OK";
}else{
$response["message"] = "KO";
}
echo json_encode($response);
?>

View File

@ -1,60 +0,0 @@
<?php
include "config.php";
$response = array();
$name = $_POST["countryName"];
$continent = $_POST["countryContinent"];
$area = $_POST["countryArea"];
$population = $_POST["countryPopulation"];
$drivingSide = $_POST["countryDrivingSide"];
// $flag = $_FILES["countryFlag"];
// $target_dir = "../assets/img/flags/";
// $target_file = $target_dir . fileNamer();
// $uploadOk = 1;
// $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// // Check if image file is a actual image or fake image
// if(true) {
// $check = getimagesize($flag["tmp_name"]);
// if($check !== false) {
// echo "File is an image - " . $check["mime"] . ".";
// $uploadOk = 1;
// } else {
// echo "File is not an image.";
// $uploadOk = 0;
// }
// if (move_uploaded_file($flag["tmp_name"], $target_file)) {
// echo "The file ". htmlspecialchars( basename( $flag["name"])). " has been uploaded.";
// $response["message"] = "OK";
// } else {
// echo "Sorry, there was an error uploading your file.";
// }
// }
$sqlString = "INSERT INTO cs_countries (cs_country_name, cs_country_continent, cs_country_area, cs_country_population, cs_country_drivingSide)";
$sqlString .= " VALUES ('$name', '$continent', $area, $population, '$drivingSide')";
$sql = mysqli_query($con, $sqlString);
if($sql){
$response["message"] = "OK";
}else{
$response["message"] = "KO";
}
// function fileNamer(){
// $today = date('YmdHi');
// $startDate = date('YmdHi', strtotime('2012-03-14 09:06:00'));
// $range = $today - $startDate;
// $rand = rand(0, $range);
// return $startDate + $rand;
// }
// $response["message"] = "OK";
echo json_encode($response);
echo json_encode($_POST);
// echo json_encode($_FILE);
?>

View File

@ -1,14 +0,0 @@
<?php
include "config.php";
$sqlString = "SELECT * FROM cs_countries";
$sth = mysqli_query($con, $sqlString);
$output = array();
while ($row = mysqli_fetch_assoc($sth)) {
$output[] = $row;
}
echo json_encode($output);
?>

View File

@ -1,10 +0,0 @@
<?php
function fileNamer(){
$today = date('YmdHi');
$startDate = date('YmdHi', strtotime('2012-03-14 09:06:00'));
$range = $today - $startDate;
$rand = rand(0, $range);
return $startDate + $rand;
}
echo fileNamer();
?>