Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php $max_no_img=4; // Maximum number of images value to be set here echo "&lt;form method=post action='' enctype='multipart/form-data'&gt;"; echo "&lt;table border='0' width='400' cellspacing='0' cellpadding='0' align=center&gt;"; for($i=1; $i&lt;=$max_no_img; $i++){ echo "&lt;tr&gt;&lt;td&gt;Images $i&lt;/td&gt;&lt;td&gt; &lt;input type=file name='images[]' class='bginput'&gt;&lt;/td&gt;&lt;/tr&gt;"; } echo "&lt;tr&gt;&lt;td colspan=2 align=center&gt;&lt;input type=submit value='Add Image'&gt;&lt;/td&gt;&lt;/tr&gt;"; echo "&lt;/form&gt; &lt;/table&gt;"; while(list($key,$value) = each($_FILES['images']['name'])) { //echo $key; //echo "&lt;br&gt;"; //echo $value; //echo "&lt;br&gt;"; if(!empty($value)){ // this will check if any blank field is entered $filename =rand(1,100000).$value; // filename stores the value $filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line $add = "upload/$filename"; // upload directory path is set //echo $_FILES['images']['type'][$key]; // uncomment this line if you want to display the file type //echo "&lt;br&gt;"; // Display a line break copy($_FILES['images']['tmp_name'][$key], $add); echo $add; // upload the file to the server chmod("$add",0777); // set permission to the file. } } ?&gt; &lt;/body&gt; &lt;/html&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