Pure PHP Upload 3 Support Product Page

Answered

File upload filename not retained when updating table

Asked 19 Mar 2014 12:03:04
1
has this question
19 Mar 2014 12:03:04 David Woolley posted:
I know this issue has been reported before in another post, but no resolution yet.
Pure PHP Upload 3.02 with DW CS6.
Update Record does not retain the filename of the uploaded file if another field in the table is updated. Insert Record works fine.

I've been trying to resolve this myself for days now but coming up against a brick wall! Endless permutations!
Filename always gets overwritten by NULL in the table.
I'm restricting file extension to zip as I will use the ZIP Processor PHP 3 after I've sorted this issue. Here is the code with the input statement included as well. No redirect yet while I troubleshoot this page.

<?php require_once('../ScriptLibrary/incPureUpload.php'); ?>
<?php 
//*** Pure PHP File Upload 3.0.1
// Process form form1
$ppu = new pureFileUpload();
$ppu->nameConflict = "uniq";
$ppu->storeType = "file";
$ppu->progressBar = "vista_look.htm";
$ppu->progressWidth = 300;
$ppu->progressHeight = 100;
$ppu->path = "../presentations_vm";
$ppu->allowedExtensions = "zip"; // "custom"
$ppu->redirectUrl = "";
$ppu->checkVersion("3.0.1");
$ppu->doUpload();
?>
<?php
// Cancel button before UPDATE RECORD - DGW
if (array_key_exists('Cancel', $_POST)) {
	header('Location: admin.php');
	exit;
}
?>
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE cases SET category_id=%s, museum_no=%s, case_no=%s, other_ref_no=%s, snomed=%s, icd10=%s, title=%s, patientdata=%s, grosspathology=%s, histology=%s, `comment`=%s, presentation=%s, web_url=%s, anat_diag=%s, `references`=%s WHERE case_id=%s",
                       GetSQLValueString($_POST['category_id'], "int"),
                       GetSQLValueString($_POST['museum_no'], "text"),
                       GetSQLValueString($_POST['case_no'], "text"),
                       GetSQLValueString($_POST['other_ref_no'], "text"),
                       GetSQLValueString($_POST['snomed'], "text"),
                       GetSQLValueString($_POST['icd10'], "text"),
                       GetSQLValueString($_POST['title'], "text"),
                       GetSQLValueString($_POST['patientdata'], "text"),
                       GetSQLValueString($_POST['grosspathology'], "text"),
                       GetSQLValueString($_POST['histology'], "text"),
                       GetSQLValueString($_POST['comment'], "text"),
                       GetSQLValueString($ppu->files("presentation")->fileName, "text"),
                       GetSQLValueString($_POST['web_url'], "text"),
                       GetSQLValueString($_POST['anat_diag'], "text"),
                       GetSQLValueString($_POST['references'], "text"),
                       GetSQLValueString($_POST['case_id'], "int"));

  mysql_select_db($database_connDigiPath, $connDigiPath);
  $Result1 = mysql_query($updateSQL, $connDigiPath) or die(mysql_error());
}
?>
.
.
.
<input name="presentation" type="file" id="presentation" onchange="<?php echo $ppu->getValidateCode() ?>;return document.MM_returnValue" value="<?php echo $row_rsCases['presentation']; ?>" size="32" />

Replies

Replied 20 Mar 2014 10:22:40
20 Mar 2014 10:22:40 Teodor Kuduschiev replied:
Hello,
Please change:
presentation=%s to presentation=IFNULL(%s,presentation) this will be improved in the next update.
Replied 20 Mar 2014 13:46:45
20 Mar 2014 13:46:45 David Woolley replied:
Thanks so much Teodor!
That did the trick. Hope the next PPU3 update does this automatically.
By the way I can't get the Progress Bars working - using PHP 5.4.7
Cheers
Dave
Replied 20 Mar 2014 15:00:59
20 Mar 2014 15:00:59 tim martyn replied:
Great, works like a dream. Thanks a lot Teodor, much appreciated.

(and thanks Dave for reposting)
Replied 26 Mar 2014 16:27:02
26 Mar 2014 16:27:02 Teodor Kuduschiev replied:
Hello
This problem is fixed in the latest version. Please update.
Replied 18 Jun 2015 17:45:41
18 Jun 2015 17:45:41 Adrian Leontovich replied:
This is NOT fixed in the latest version. I just installed it and it's still an issue. One difference is that I'm using mySQLi, so I don't know if that's a part of the problem or not. Here's my mySQLi/PHP update code:


if (isset($_POST["button"]) || isset($_POST["button_x"])) {
  $UpdateQuery = new WA_MySQLi_Query($Conn);
  $UpdateQuery->Action = "update";
  $UpdateQuery->Table = "TableName";
  $UpdateQuery->bindColumn("FileName", "s", "".((isset($_FILES["fileField"]))?$_FILES["fileField"]["name"]:"")  ."", "WA_DEFAULT");
  $UpdateQuery->addFilter("DocID", "=", "i", "".($_GET['DocID'])  ."");
  $UpdateQuery->execute();
}
Replied 05 Jun 2016 10:55:02
05 Jun 2016 10:55:02 Nick Green replied:
I have the exact same problem and have only just installed Pure Upload 3 today.

Background
Can't get on with the DMXzone Connector functions so using MySQLi from Webassist but that shouldn't be an issue.
  • Insert function working great.
  • Update function (when changing image) working great.
  • If I don't change the image and submit the form the image is overwritten in the database.


I have binded my Recordset value to the file field and when the page is loaded I can see it in source code. However when submitting the form it's just overwritten without keeping the value of the image field.

My update function is pretty much the same as Adrian's...any suggestions?

Cheers
Nick


UPDATE @ 12:00 on 5th June 2016.

I've managed a work around based on a post above. In essence I have replaced the WA_DEFAULT value at the end of the bindColumn to be the recordset value. Therefore if the value that Pure Upload is seeing is blank, then I just replace the default value with what the RS had anyway. Make sure that you have your recordset before the Pure Upload function otherwise it won't see the original data.


My fix
$UpdateQuery->bindColumn("image", "s", "".((isset($_POST["image"]))?$_POST["image"]:"")  ."", $rsProductDetail->getColumnval("image"));


This will definitely help you Adrian, but not sure about others. This really should be fixed as a really common function to use.
Replied 10 May 2024 11:04:44
10 May 2024 11:04:44 User  replied:
I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. telegram中文版
Replied 10 May 2024 11:05:01
10 May 2024 11:05:01 User  replied:
I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. telegram中文版
Replied 10 May 2024 12:19:51
10 May 2024 12:19:51 User  replied:
You can be absolutely sure that you will be receiving the most reliable services by using such agencies. Delhi is a perfect place for a honeymoon or even a simple vacation with your loved one.
Patparganj Escorts
Escorts in Piragarhi
Pitampura Escorts Service
Pragati Maidan Call Girls
Call Girls in Pratap Vihar
Replied 11 May 2024 17:19:52
11 May 2024 17:19:52 User  replied:
The website is looking bit flashy and it catches the traffic eyes. layout is beautiful clean and a enjoyable adherent without problems reached interface. telegeram官网
Replied 12 May 2024 11:19:58
12 May 2024 11:19:58 User  replied:
This is such a nice useful resource that you are supplying and also you meet the price of it away for forgive. I hero reward seeing websites that take at the value of supplying a setting useful resource for set wandering. it’s far the primeval what goes on the order of comes almost about recurring. tg中文版
Replied 13 May 2024 11:13:34
13 May 2024 11:13:34 User  replied:
This is a brilliant blog! I'm very happy with the comments!.. telegram中文
Replied 14 May 2024 16:21:57
14 May 2024 16:21:57 User  replied:
Every year, thousands of customers around the world choose MaroCar for a cheap car hire in Morocco. The platform operates in the main cities of the kingdom (Casablanca, Marrakech, Tangiers, Rabat ...) and delivers its cars to the address of your choice or directly to the main airports in the country. Telegram下载
Replied 14 May 2024 21:37:32
14 May 2024 21:37:32 Graceful Gabrielle replied:
Pure PHP Upload 3 Support is a fantastic tool for seamlessly uploading files with ease and efficiency. As for MOVERS & PACKERS, they're your go-to professionals for all your moving needs—reliable, local, and budget-friendly. With this dynamic duo, you can move stress-free and enjoy a smooth transition to your new home or office.
Replied 15 May 2024 15:20:38
15 May 2024 15:20:38 User  replied:
You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant 电报
Replied 16 May 2024 17:34:02
16 May 2024 17:34:02 User  replied:
I gotta favorite this website it seems very helpful . telegram中文
Replied 18 May 2024 12:01:53
18 May 2024 12:01:53 User  replied:
I need to to thank you for ones time for this particularly fantastic read!! I definitely really liked every part of it and i also have you saved to fav to look at new information in your site. 纸飞机中文
Replied 19 May 2024 17:27:14
19 May 2024 17:27:14 User  replied:
You have done a great job on this article. It’s very readable and highly intelligent. You have even managed to make it understandable and easy to read. You have some real writing talent. Thank you. telegram下载
Replied 21 May 2024 07:21:58
21 May 2024 07:21:58 User  replied:
You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant 电报中文
Replied 22 May 2024 08:56:28
22 May 2024 08:56:28 User  replied:
I am for the first time here. I found this board and I in finding It truly helpful & it helped me out a lot. I hope to present something back and help others such as you helped me. telegram下载

Reply to this topic