PHP - Upload multiple images


so started code found on http://lpmj.net/7.php (example 15) uploads image, writes variable, , displays it. want modify instead writes array , displays, , can continue upload images subsequent array position , display them all, opposed recent, case now. can see set put in array , after displaying, move next position, given html creates button not dynamic, sort of stuck. here's have now:

code:
  <?php // upload.php  $m=0;  echo <<<_end  <html><head><title>php form upload</title></head><body>  <form method='post' action='upload.php' enctype='multipart/form-data'>  select file: <input type='file' name='filename' size='10' />  <input type='submit' value='upload' />  </form>  _end;  display();  function display(){  if ($_files)  {  	$name[$m] = $_files['filename']['name'];  	move_uploaded_file($_files['filename']['tmp_name'], $name[$m]);  	echo "uploaded image '$name[$m]'<br /><img src='$name[$m]' />";          $m++;  }  }  echo "</body></html>";  ?>  
thanks!
 

two things:

[1] if write array contents won't persist between uploads. if need store image locations, need store them flat file or database.

[2] if want, can include multiple <inputs> on page, so:
code:
  <input type='file[]' name='filename' size='10' />  <input type='file[]' name='filename' size='10' />  <input type='file[]' name='filename' size='10' />  <input type='file[]' name='filename' size='10' />  
then access:
code:
  $name = array();  $name[0] = $_files['filename']['name'][0]  $name[1] = $_files['filename']['name'][1]  $name[2] = $_files['filename']['name'][2]  $name[3] = $_files['filename']['name'][3]  
etc.

[3] dynamically add/remove inputs, may quickest use client side javascript.
 


Forums Special Interests Web Design and Development


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

Comments

Popular posts from this blog

Has to be the funniest headline ive ever seen

Man Brings Goat to Apple Store and has Pizza Delivered

Elusive Ninja: The Shadowy Thief - Can you survive the fast-paced ninja chaos?