function restoreState() { // must call super parent::restoreState(); $fileInputName = $this->getInputFileName(); if (isset($_FILES[$fileInputName])) { $count = count($_FILES[$fileInputName]['name']); $this->hasMultipleSimultaneousUploads = $count > 1; for ($i = 0; $i < $count; $i++) { // we silently eat UPLOAD_ERR_NO_FILE; otherwise we keep track of success & error uploads if ($_FILES[$fileInputName]['error'][$i] === UPLOAD_ERR_NO_FILE) { continue; } $upload = new WFUploadedFile_Basic($_FILES[$fileInputName]['tmp_name'][$i], $_FILES[$fileInputName]['type'][$i], $_FILES[$fileInputName]['name'][$i]); $error = NULL; // check for errors if ($_FILES[$fileInputName]['error'][$i] == UPLOAD_ERR_OK) { if (!is_uploaded_file($_FILES[$fileInputName]['tmp_name'][$i])) { $error = new WFUploadError("File: '{$_FILES[$fileInputName]['name'][$i]}' is not a legitimate PHP upload. This is a hack attempt.", WFUploadError::ERR_HACKY); } } else { $error = WFUploadError::createFromPhpUploadError($_FILES[$fileInputName]['error'][$i]); } $this->uploads[] = compact('upload', 'error'); } } }
function restoreState() { // must call super parent::restoreState(); if (isset($_FILES[$this->name])) { if (is_array($_FILES[$this->name]['name'])) { throw new Exception("WFPostletUpload expected a single upload files but multiple found."); } if ($_FILES[$this->name]['error'] == UPLOAD_ERR_OK) { if (is_uploaded_file($_FILES[$this->name]['tmp_name'])) { $this->hasUpload = true; $this->tmpFileName = $_FILES[$this->name]['tmp_name']; $this->originalFileName = $_FILES[$this->name]['name']; $this->mimeType = $_FILES[$this->name]['type']; } else { throw new WFException("File: '{$_FILES[$this->name]['name']}' is not a legitimate PHP upload. This is a hack attempt."); } } else { if ($_FILES[$this->name]['error'] != UPLOAD_ERR_NO_FILE) { // send back error+noretry print "POSTLET REPLY\nPOSTLET:NO\nPOSTLET:UNKNOWN ERROR\nPOSTLET:ABORT THIS\nEND POSTLET REPLY"; exit; } } } }