Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created August 24, 2022 09:26
Show Gist options
  • Save codeforfun-jp/44b421f8e87904652a389fd0dbaa9229 to your computer and use it in GitHub Desktop.
Save codeforfun-jp/44b421f8e87904652a389fd0dbaa9229 to your computer and use it in GitHub Desktop.
Save Image File with PHP & MySQL - #8-2
<?php
require_once('functions.php');
$pdo = connectDB();
$err_msg = '';
// 画像を取得
$sql = 'SELECT * FROM images ORDER BY created_at DESC';
$stmt = $pdo->prepare($sql);
$stmt->execute();
$images = $stmt->fetchAll();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// 画像を保存
if (!empty($_FILES['image']['name'])) {
$name = $_FILES['image']['name'];
$type = $_FILES['image']['type'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment