here's a couple of the more tricky code snippets which should make it easy for folks to see how a multiple file upload select can work - the rest is basically a lot of interaction with the database - storing / retrieving the upload list.

Its a bit tricky but worth it though - the users responcible for uploads via the system I built have been saying it makes their lives a lot easier.

If i get time i'll try and generalise the whole thing into an absract class that folks can use...


// remove a file from upload target list
function removeFileFromUploadList() {
$this->getFileUploadList(); // get the upload list from the database
$selectedFileList = $_POST['selectedFileList']; // an array of selected values from the multiple select box
// diff the arrays, store the new list
if ((sizeof($this->uploadFileList) >= 1) && ($selectedFileList != "")) {
$this->uploadFileList = array_values(array_diff($this->uploadFileList,$selectedFileList)); // subtract remove items
$this->storeFileUploadList();
}
}


// add pipe encoding to an array (file upload list) and return a string for storage in db
function addPipeEncoding($array) {
for ($i = 0; $i < sizeof($array); $i++) {
$addPipe = ((sizeof($array) == 1) || ($i == sizeof($array)-1)) ? "" : "|";
$returnValue .= $array[$i].$addPipe;
}
return $returnValue;
}


// remove pipe encoding from string
function removePipeEncoding($encodedString) {
$split = explode("|",$encodedString);
for ($i = 0; $i < sizeof($split); $i++) {
if ($split[$i] != "") {
$returnArray[] = $split[$i];
}
}
return $returnArray;
}


_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to