HOWTOlabs SWFUpload
Using Flash with PHP to upload content

Related
Elsewhere

Specifically, how to use the Multi-Instance upload features of SWFUpload.

Download SWFUpload v2.2.0.1 Samples.zip from SWFUpload.  Unzip the file on a Linux/Unix server.  Now make a test directory to place the components for your Multi-Instance upload site.  Ok, now review the files in samples, and perform the file copies cited below to your test directory.

$ ls -R samples

  demos  Sample-Demo Changelog.txt  samples

  ...

  ./demos/css:
  default.css

  ...

  ./demos/images:
  cancelbutton.gif  header-bg.jpg  logo.gif

  ./demos/multiinstancedemo:
  index.php  js  upload.php  XPButtonUploadText_61x22.png

  ./demos/multiinstancedemo/js:
  fileprogress.js  handlers.js  swfupload.queue.js

  ...

  ./demos/swfupload:
  swfuploadbutton.swf  swfupload.js  swfupload.swf

  ...

  ./samples/php:
  example.php  test.php  upload.php  web.config

$ ls -R test

  default.css  fileprogress.js     gfx       handlers.js  index.php
  swfupload    swfupload.queue.js  tags.txt  upload.php

  ./gfx:
  cancelbutton.gif  header-bg.jpg  logo.gif

  ./swfupload:
  swfupload.js  swfupload.swf

$ cp /demos/css/default.css test

$ cp /demos/multiinstancedemo/js/fileprogress.js test
$ cp /demos/multiinstancedemo/js/handlers.js test
$ cp /demos/multiinstancedemo/js/swfupload.queue.js test

$ cp /demos/multiinstancedemo/index.php test

$ cp /demos/multiinstancedemo/XPButtonUploadText_61x22.png test

$ cp /samples/php/upload.php test
  (the one in /demos/multiinstancedemo is only a stub)

$ cp demos/images/cancelbutton.gif test/gfx
$ cp demos/images/header-bg.jpg test/gfx
$ cp demos/images/logo.gif test/gfx

$ cp demos/swfupload/swfupload.js test/swfupload
$ cp demos/swfupload/swfupload.swf test/swfupload 

Ok, now tailor files in test to suit your needs ...

$ diff samples/demos/css/default.css test/default.css 

  131c131
  < background: #313131 url(../images/header-bg.jpg) repeat-x top left;
  ---
  > background: #313131 url(gfx/header-bg.jpg) repeat-x top left;
  138c138
  < background: url(../images/logo.gif) no-repeat 20px 20px;
  ---
  > background: url(gfx/logo.gif) no-repeat 20px 20px;
  320c320
  < background-image: url(../images/cancelbutton.gif);
  ---
  > background-image: url(gfx/cancelbutton.gif);

$ diff samples/demos/multiinstancedemo/index.php test/index.php 

  15,19c15,19
  < <link href="../css/default.css" rel="stylesheet" type="text/css" />
  < <script type="text/javascript" src="../swfupload/swfupload.js"></script>
  < <script type="text/javascript" src="js/swfupload.queue.js"></script>
  < <script type="text/javascript" src="js/fileprogress.js"></script>
  < <script type="text/javascript" src="js/handlers.js"></script>
  ---
  > <link href="default.css" rel="stylesheet" type="text/css" />
  > <script type="text/javascript" src="swfupload/swfupload.js"></script>
  > <script type="text/javascript" src="swfupload.queue.js"></script>
  > <script type="text/javascript" src="fileprogress.js"></script>
  > <script type="text/javascript" src="handlers.js"></script>
  54c54
  < flash_url : "../swfupload/swfupload.swf",
  ---
  > flash_url : "swfupload/swfupload.swf",
  73c73
  < file_types : "*.jpg;*.gif;*.png",
  ---
  > file_types : "*.jpg;*.gif;*.png;*.txt",
  96c96
  < flash_url : "../swfupload/swfupload.swf",
  ---
  > flash_url : "swfupload/swfupload.swf",

$ diff samples/samples/php/upload.php test/upload.php

  61c61,62
  < $save_path = getcwd() . "/uploads/";
  ---
  >  $save_path = "/var/www/ricks/ricks.motmd.com/new/";
  > // ve_path = getcwd() . "/uploads/";
  64c65
  < $extension_whitelist = array("jpg", "gif", "png");	// Allowed file extensions
  ---
  > $extension_whitelist = array("jpg", "gif", "png", "txt");	// Allowed file extensions
  163a165,168
  > /*  !!!!!!! for some reason must output something to standard out or
  >     Flash stalls thinking upload is still in progress  */
  >  echo "Looks like we did it?\n";