Jump to content

Search the Community

Showing results for tags 'uploading images with arrays'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hi everyone. I'm have a website I took over and I'm looking on the page to upload photos. When you upload a photo you can only choose one from that window and then you have to keep repeating the process if there are more than one image in the file. Could anyone please help me or point me in the right direction. <?php include "../sql.php"; if ($_SESSION['admin'] != 1) { header("Location: /admin"); die(); } $file = $_FILES['Filedata']['name']; $tmpfile = $_FILES['Filedata']['tmp_name']; $name = md5(microtime()); $ext = strtolower(end(split("\.", $file))); if ($ext == "png") $img = imagecreatefrompng($tmpfile) or die("failed"); elseif ($ext == "gif") $img = imagecreatefromgif($tmpfile) or die("failed"); else $img = imagecreatefromjpeg($tmpfile) or die("failed"); $width = imageSX($img); $height = imageSY($img); for ($i = 0; $i <= 1; $i++) { if ($i == 1) { //$target_width = 750; $target_width = 640; $target_height = ceil($target_width * 3/4); } else { $target_width = 105; $target_height = ceil($target_width * 3/4); } if ($width > $target_width || $height > $target_height) { $tr = $target_width/$target_height; $ir = $width/$height; if ($ir > $tr) // too wide $target_height = $target_width / $ir; else // too tall $target_width = $target_height * $ir; } else { $target_width = $width; $target_height = $height; } if ($i == 0) { $car_id = intval($_POST['car_id']); mysql_query("insert into images (car_id) values (" . $car_id . ")"); $img_id = mysql_insert_id(); } $target_dir = "../images/vehicles"; //mkdir($target_dir, 0777, true); $new_img = ImageCreateTrueColor($target_width, $target_height); imagecopyresampled($new_img, $img, 0, 0, 0, 0, $target_width, $target_height, $width, $height); imagejpeg($new_img, $target_dir . "/" . $car_id . "-" . $img_id . ($i == 0 ? "t" : "") . ".jpg", 90); //die($target_dir . "/" . $car_id . "-" . $img_id . ($i == 0 ? "t" : "") . ".jpg"); } unlink($_FILES['Filedata']['tmp_name']); if (end(mysql_fetch_array(mysql_query("select count(*) from images where main=1 and car_id=" . $car_id), MYSQL_ASSOC)) == 0) mysql_query("update images set main=1 where car_id=" . $car_id . " limit 1"); header("Location: carpics.php?id=" . $car_id); ?> Thank you in advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.