次のスクリプトを使用して、フォームを介して複数の画像をアップロード、サイズ変更、および保存しようとしています。それは機能していません...1つの入力に分解されてforeachが削除されていません。アップロードスクリプトとサイズ変更スクリプトを組み合わせてから、フォームアクションを組み合わせたスクリプトにリダイレクトしてみました。それを機能させることはできません。次に、move_uploaded_fileを使用してアップロードされたファイルをupload.phpからSimpleImage.phpに移動しようとしていますが、どちらも機能していないようです。空白のページだけでエラーが発生することはありません。後でより良い検証を追加しますが、今それを機能させることを試みます。たくさんのコードで申し訳ありませんが、参考のためにすべてをここに置きたかっただけです。
私の質問:upload.phpを取得して画像をサイズ変更スクリプトに送信するにはどうすればよいですか、またはその逆にする必要がありますか?なぜ機能しないのか、エラーが表示されるのかについてのアイデアはありますか?
私はphpに不慣れですが、これを理解することを非常に決心しています!私はあなたが私に投げかけることができるすべてのアドバイスおよび/または侮辱を取ります!私は両方から学びます!:) 前もって感謝します!!!
フォーム:
<?php
   if( isset($_POST['submit']) ) {
      include('SimpleImage.php');
      $image = new SimpleImage();
      $image->load($_FILES['uploaded_image']['tmp_name']);
      $image->resizeToWidth(500);
      $image->save("uploads/uploadedfiles/".$pictures);
   } else {
?>
<form action="/upload.php" method="post" enctype="multipart/form-data"></br>
<input type="file" name="uploaded_image[]" accept="image/gif, image/jpeg, image/png" /> <br /> 
<input type="file" name="uploaded_image[]" accept="image/gif, image/jpeg, image/png" /> <br /> 
<input type="file" name="uploaded_image[]" accept="image/gif, image/jpeg, image/png" /> <br /> 
<input type="file" name="uploaded_image[]" accept="image/gif, image/jpeg, image/png" /> <br /> 
<input type="file" name="uploaded_image[]" accept="image/gif, image/jpeg, image/png" /> <br /> 
<input type="file" name="uploaded_image[]" accept="image/gif, image/jpeg, image/png" /> <br />    <br />  
<input type="hidden" name="MAX_FILE_SIZE" value="48000000" /> *Images must be no more than     5MB.<br /> .jpg, .gif & .png files accepted only.<br /><br />
<input type="submit" value="Upload"> </p> </form>
upload.php:
<?php
header("Location:confirmationpage.php");
foreach ($_FILES["pictures"]["error"] as $key => $error) {
  if (($_FILES["pictures"]["type"] == "image/gif")
  || ($_FILES["pictures"]["type"] == "image/jpeg")
  || ($_FILES["pictures"]["type"] == "image/png" )
  && ($_FILES["pictures"]["size"] < 50000))
   {
       move_uploaded_file(
         $_FILES["pictures"]["tmp_name"][$key],     "/SimpleImage.php" . $_FILES["pictures"]["name"][$key]); 
   }
}
 ?>
サイズ変更スクリプト(SimpleImage.php):
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
* File: SimpleImage.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 08/11/06
* Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
* http://www.gnu.org/licenses/gpl.html
*
*/
class SimpleImage {
   var $image;
   var $image_type;
   function load($uploaded_image) {
  $image_info = getimagesize($uploaded_image);
  $this->image_type = $image_info[2];
  if( $this->image_type == IMAGETYPE_JPEG ) {
     $this->image = imagecreatefromjpeg($uploaded_image);
  } elseif( $this->image_type == IMAGETYPE_GIF ) {
     $this->image = imagecreatefromgif($uploaded_image);
  } elseif( $this->image_type == IMAGETYPE_PNG ) {
     $this->image = imagecreatefrompng($uploaded_image);
  }
   }
   function save($uploaded_image, $image_type=IMAGETYPE_JPEG, $compression=75,     $permissions=null) {
  if( $image_type == IMAGETYPE_JPEG ) {
     imagejpeg($this->image,$uploaded_image,$compression);
  } elseif( $image_type == IMAGETYPE_GIF ) {
     imagegif($this->image,$uploaded_image);
  } elseif( $image_type == IMAGETYPE_PNG ) {
     imagepng($this->image,$uploaded_image);
  }
  if( $permissions != null) {
     chmod($uploaded_image,$permissions);
  }
   }
   function output($image_type=IMAGETYPE_JPEG) {
  if( $image_type == IMAGETYPE_JPEG ) {
     imagejpeg($this->image);
  } elseif( $image_type == IMAGETYPE_GIF ) {
     imagegif($this->image);
  } elseif( $image_type == IMAGETYPE_PNG ) {
     imagepng($this->image);
  }
   }
   function getWidth() {
  return imagesx($this->image);
   }
   function getHeight() {
  return imagesy($this->image);
   }
   function resizeToHeight($height) {
  $ratio = $height / $this->getHeight();
  $width = $this->getWidth() * $ratio;
  $this->resize($width,$height);
   }
   function resizeToWidth($width) {
  $ratio = $width / $this->getWidth();
  $height = $this->getheight() * $ratio;
  $this->resize($width,$height);
   }
   function scale($scale) {
  $width = $this->getWidth() * $scale/100;
  $height = $this->getheight() * $scale/100;
  $this->resize($width,$height);
   }
   function resize($width,$height) {
  $new_image = imagecreatetruecolor($width, $height);
  imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this-        >getWidth(), $this->getHeight()); 
  $this->image = $new_image;
   }      
}
?>