Note that there are some explanatory texts on larger screens.

plurals
  1. POUploading multiple images at the same time
    text
    copied!<p>I am trying to upload two images at the same time using php. When I run the code below nothing shows as error and images are not uploaded to the folder I moved them to. The first is a thumbnail image while the second is the actual image.</p> <p>I have added <code>error_reporting(E_ALL); ini_set('display_errors', '1');</code> and no error is shown on the screen.</p> <pre><code>&lt;?php error_reporting(E_ALL); ini_set('display_errors', '1'); if(isset($_POST['submit'])){ if (isset($_FILES['newsthumb']) &amp;&amp; isset($_FILES['newsmain'])) { $allowedExts = array("jpg", "jpeg", "gif", "png"); $thumbimage = $_FILES['newsthumb']; $mainimage = $_FILES['newsmain']; $thumbname = strtolower($thumbimage['name']); $mainmane = strtolower($mainimage['name']); $thumbname = preg_replace("/[^A-Z0-9._-]/i", "_", $thumbname); $mainmane = preg_replace("/[^A-Z0-9._-]/i", "_", $mainmane); $thumbname = $thumbname.uniqid(); $mainmane = $thumbname.uniqid(); if (($thumbimage['size'] &gt; 350000) || ($mainmane['size'] &gt; 350000)) { $error[] = "One/Both of the files are too large.&lt;br&gt;"; } $uploaddir = "images/newsimage/"; $thumbsuccess = move_uploaded_file($thumbimage["tmp_name"], $uploaddir.$thumbname); $mainsuccess = move_uploaded_file($mainimage["tmp_name"], $uploaddir.$mainmane ); } } ?&gt; </code></pre> <p>Here is the HTML form I'm using :</p> <pre><code> &lt;form enctype="multipart/form-data" action="&lt;?php echo htmlentities($_SERVER['SCRIPT_NAME']) ?&gt;" method="post"&gt; &lt;input type="hidden" name="MAX_FILE_SIZE" value="9000000"&gt; &lt;h3&gt;Thumbnail News Image: &lt;/h3&gt; &lt;input name='newsthumb' type="file" class='Input_file' /&gt; &lt;h3&gt;Full Image:&gt;&lt;/h3&gt; &lt;input name='newsmain' type="file" class='Input_file' /&gt; &lt;input type="submit" name="commit" value="send"&gt; &lt;/form&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload