Continue insertion did not work if the form had special controls like file upload from client, file upload from server or BLOB streaming upload

This commit is contained in:
Marc Delisle
2010-12-06 12:49:08 -05:00
parent aa38371c48
commit f30125fcd3
2 changed files with 56 additions and 121 deletions

View File

@@ -263,24 +263,19 @@ class PMA_File
* @param string $rownumber
* @return boolean success
*/
function setUploadedFromTblChangeRequest($key, $rownumber = null)
function setUploadedFromTblChangeRequest($key, $rownumber)
{
if (! isset($_FILES['fields_upload_' . $key])) {
if (! isset($_FILES['fields_upload']) && ! isset($_FILES['fields_upload']['name']['multi_edit'][$rownumber][$key])) {
return false;
}
$file = $_FILES['fields_upload_' . $key];
if (null !== $rownumber) {
$file = PMA_File::fetchUploadedFromTblChangeRequestMultiple($file, $rownumber);
}
$file = PMA_File::fetchUploadedFromTblChangeRequestMultiple($_FILES['fields_upload'], $rownumber, $key);
// for blobstreaming
$is_bs_upload = FALSE;
// check if this field requires a repository upload
if (isset($_REQUEST['upload_blob_repo_' . $key])) {
$is_bs_upload = ($_REQUEST['upload_blob_repo_' . $key]['multi_edit'][0] == "on") ? TRUE : FALSE;
if (isset($_REQUEST['upload_blob_repo']['multi_edit'][$rownumber][$key])) {
$is_bs_upload = ($_REQUEST['upload_blob_repo']['multi_edit'][$rownumber][$key] == "on") ? TRUE : FALSE;
}
// if request is an upload to the BLOB repository
if ($is_bs_upload) {
@@ -340,11 +335,11 @@ class PMA_File
* strips some dimension from the multi-dimensional array from $_FILES
*
* <code>
* $file['name']['multi_edit'][$rownumber] = [value]
* $file['type']['multi_edit'][$rownumber] = [value]
* $file['size']['multi_edit'][$rownumber] = [value]
* $file['tmp_name']['multi_edit'][$rownumber] = [value]
* $file['error']['multi_edit'][$rownumber] = [value]
* $file['name']['multi_edit'][$rownumber][$key] = [value]
* $file['type']['multi_edit'][$rownumber][$key] = [value]
* $file['size']['multi_edit'][$rownumber][$key] = [value]
* $file['tmp_name']['multi_edit'][$rownumber][$key] = [value]
* $file['error']['multi_edit'][$rownumber][$key] = [value]
*
* // becomes:
*
@@ -360,16 +355,17 @@ class PMA_File
* @static
* @param array $file the array
* @param string $rownumber
* @param string $key
* @return array
*/
function fetchUploadedFromTblChangeRequestMultiple($file, $rownumber)
function fetchUploadedFromTblChangeRequestMultiple($file, $rownumber, $key)
{
$new_file = array(
'name' => $file['name']['multi_edit'][$rownumber],
'type' => $file['type']['multi_edit'][$rownumber],
'size' => $file['size']['multi_edit'][$rownumber],
'tmp_name' => $file['tmp_name']['multi_edit'][$rownumber],
'error' => $file['error']['multi_edit'][$rownumber],
'name' => $file['name']['multi_edit'][$rownumber][$key],
'type' => $file['type']['multi_edit'][$rownumber][$key],
'size' => $file['size']['multi_edit'][$rownumber][$key],
'tmp_name' => $file['tmp_name']['multi_edit'][$rownumber][$key],
'error' => $file['error']['multi_edit'][$rownumber][$key],
);
return $new_file;
@@ -388,16 +384,15 @@ class PMA_File
*/
function setSelectedFromTblChangeRequest($key, $rownumber = null)
{
if (null !== $rownumber) {
if (! empty($_REQUEST['fields_uploadlocal_' . $key]['multi_edit'][$rownumber])
&& is_string($_REQUEST['fields_uploadlocal_' . $key]['multi_edit'][$rownumber])) {
if (! empty($_REQUEST['fields_uploadlocal']['multi_edit'][$rownumber][$key])
&& is_string($_REQUEST['fields_uploadlocal']['multi_edit'][$rownumber][$key])) {
// ... whether with multiple rows ...
// for blobstreaming
$is_bs_upload = FALSE;
// check if this field requires a repository upload
if (isset($_REQUEST['upload_blob_repo_' . $key])) {
$is_bs_upload = ($_REQUEST['upload_blob_repo_' . $key]['multi_edit'][0] == "on") ? TRUE : FALSE;
if (isset($_REQUEST['upload_blob_repo']['multi_edit'][$rownumber][$key])) {
$is_bs_upload = ($_REQUEST['upload_blob_repo']['multi_edit'][$rownumber][$key] == "on") ? TRUE : FALSE;
}
// is a request to upload file to BLOB repository using uploadDir mechanism
@@ -434,58 +429,10 @@ class PMA_File
PMA_File::setRecentBLOBReference($blob_url);
} // end if ($is_bs_upload)
return $this->setLocalSelectedFile($_REQUEST['fields_uploadlocal_' . $key]['multi_edit'][$rownumber]);
return $this->setLocalSelectedFile($_REQUEST['fields_uploadlocal']['multi_edit'][$rownumber][$key]);
} else {
return false;
}
} elseif (! empty($_REQUEST['fields_uploadlocal_' . $key])
&& is_string($_REQUEST['fields_uploadlocal_' . $key])) {
// for blobstreaming
$is_bs_upload = FALSE;
// check if this field requires a repository upload
if (isset($_REQUEST['upload_blob_repo_' . $key]))
$is_bs_upload = ($_REQUEST['upload_blob_repo_' . $key]['multi_edit'][0] == "on") ? TRUE : FALSE;
// is a request to upload file to BLOB repository using uploadDir mechanism
if ($is_bs_upload)
{
// check if fileinfo library exists
if ($PMA_Config->get('FILEINFO_EXISTS'))
{
// attempt to init fileinfo
$finfo = finfo_open(FILEINFO_MIME);
// if fileinfo exists
if ($finfo)
{
// pass in filename to fileinfo and close fileinfo handle after
$tmp_file_type = finfo_file($finfo, $tmp_filename);
finfo_close($finfo);
}
}
else // no fileinfo library exists, use file command
$tmp_file_type = exec("file -bi " . escapeshellarg($tmp_filename));
if (!$tmp_file_type)
$tmp_file_type = NULL;
$bs_db = $_REQUEST['db'];
$bs_table = $_REQUEST['table'];
if (!$bs_db || !$bs_table)
{
$this->_error_message = $GLOBALS['strUploadErrorUnknown'];
return FALSE;
}
$blob_url = PMA_BS_UpLoadFile($bs_db, $bs_table, $tmp_file_type, $tmp_filename);
PMA_File::setRecentBLOBReference($blob_url);
} // end if ($is_bs_upload)
return $this->setLocalSelectedFile($_REQUEST['fields_uploadlocal_' . $key]);
}
return false;
}
/**
@@ -525,22 +472,10 @@ class PMA_File
// well done ...
$this->_error_message = '';
return true;
/*
} elseif ($this->setUploadedFromTblChangeRequest($key)) {
// well done ...
$this->_error_message = '';
return true;
*/
} elseif ($this->setSelectedFromTblChangeRequest($key, $rownumber)) {
// well done ...
$this->_error_message = '';
return true;
/*
} elseif ($this->setSelectedFromTblChangeRequest($key)) {
// well done ...
$this->_error_message = '';
return true;
*/
}
// all failed, whether just no file uploaded/selected or an error

View File

@@ -889,11 +889,11 @@ foreach ($rows as $row_id => $vrow) {
// check if field type is of longblob and if the table is PBMS enabled.
if (($field['pma_type'] == "longblob") && PMA_BS_IsTablePBMSEnabled($db, $table, $tbl_type)) {
echo '<br />';
echo '<input type="checkbox" name="upload_blob_repo_' . $field['Field_md5'] . $vkey . '" /> ' . __('Upload to BLOB repository');
echo '<input type="checkbox" name="upload_blob_repo' . $vkey . '[' . $field['Field_md5'] . ']" /> ' . __('Upload to BLOB repository');
}
echo '<br />';
echo '<input type="file" name="fields_upload_' . $field['Field_md5'] . $vkey . '" class="textfield" id="field_' . $idindex . '_3" size="10" ' . $unnullify_trigger . '/>&nbsp;';
echo '<input type="file" name="fields_upload' . $vkey . '[' . $field['Field_md5'] . ']" class="textfield" id="field_' . $idindex . '_3" size="10" ' . $unnullify_trigger . '/>&nbsp;';
// find maximum upload size, based on field type
/**
@@ -926,7 +926,7 @@ foreach ($rows as $row_id => $vrow) {
} elseif (!empty($files)) {
echo "<br />\n";
echo ' <i>' . __('Or') . '</i>' . ' ' . __('web server upload directory') . ':<br />' . "\n";
echo ' <select size="1" name="fields_uploadlocal_' . $field['Field_md5'] . $vkey . '">' . "\n";
echo ' <select size="1" name="fields_uploadlocal' . $vkey . '[' . $field['Field_md5'] . ']">' . "\n";
echo ' <option value="" selected="selected"></option>' . "\n";
echo $files;
echo ' </select>' . "\n";