close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Delete files not deleting files on delete record action

Thread began 2/27/2011 9:50 am by robert254422 | Last modified 7/25/2014 8:02 pm by bjgarner241692 | 3698 views | 15 replies |

robert254422

Delete files not deleting files on delete record action

Hello ...,

Using universal email 4 - feature: delete files in combination with delete record (data-assist).

On inserting and updating records and files all works well but when it gets time to delete record and associated files only the record gets deleted the associated files remain on server...

<?php
// WA Application Builder Delete
if (isset($_POST["Delete_x"])) // Trigger
{
$WA_connection = $xxx;
$WA_table = "xxx";
$WA_redirectURL = "xxx.php";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "Cat_Id";
$WA_columnTypesStr = "none,none,NULL";
$WA_fieldValuesStr = "".((isset($_POST["WADADeleteRecordID"]))?$_POST["WADADeleteRecordID"]:"") ."";
$WA_comparisonStr = "=";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_comparisions = explode("|", $WA_comparisonStr);
$WA_connectionDB = $database_site;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$deleteParamsObj = WA_AB_generateWhereClause($WA_fieldNames, $WA_columns, $WA_fieldValues, $WA_comparisions);
$WA_Sql = "DELETE FROM `" . $WA_table . "` WHERE " . $deleteParamsObj->sqlWhereClause;
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
?>
<?php
$WA_DeleteFileResult1 = false;
if(isset($_POST["Delete_x"])){
$WA_DeleteFileResult1 = WA_FileAssist_DeleteFile("../Uploads/Catalogi/", "".((isset($_POST["Cat_Omslag"]))?$_POST["Cat_Omslag"]:"") ."");
}
?>
<?php
$WA_DeleteFileResult2 = false;
if(isset($_POST["Delete_x"])){
$WA_DeleteFileResult2 = WA_FileAssist_DeleteFile("../Uploads/Catalogi/", "".((isset($_POST["Cat_Pdf"]))?$_POST["Cat_Pdf"]:"") ."");
}
?>
<?php
$WA_DeleteFileResult3 = false;
if(isset($_POST["Delete_x"])){
$WA_DeleteFileResult3 = WA_FileAssist_DeleteFile("../Uploads/Catalogi/", "".((isset($_POST["Cat_Zip"]))?$_POST["Cat_Zip"]:"") ."");
}
?>
<?php
$WA_DeleteFileResult4 = false;
if(isset($_POST["Delete_x"])){
$WA_DeleteFileResult4 = WA_FileAssist_DeleteFile("../Uploads/Catalogi/", "".((isset($_POST["Cat_Omslag2"]))?$_POST["Cat_Omslag2"]:"") ."");
}
?>
<?php
$WA_DeleteFileResult5 = false;
if(isset($_POST["Delete_x"])){
$WA_DeleteFileResult5 = WA_FileAssist_DeleteFile("../Uploads/Catalogi/", "".((isset($_POST["Cat_Omslag3"]))?$_POST["Cat_Omslag3"]:"") ."");
}
?>
<?php
$WA_DeleteFileResult6 = false;
if(isset($_POST["Delete_x"])){
$WA_DeleteFileResult6 = WA_FileAssist_DeleteFile("../Uploads/Catalogi/", "".((isset($_POST["Cat_Omslag4"]))?$_POST["Cat_Omslag4"]:"") ."");
}
?>

I hope this is enough code to see what is going wrong or what I am doing wrong...

WKR

RV

Sign in to reply to this post

Jason ByrnesWebAssist

The delete file code needs to be before the delete record code.


PHP is executed form top to bottom, currently you have the delete record being executed before the delete file code.
the delete record behavior is set to redirect to another page, the redirect is occurring before the delete file code has a change to execute.

move the delete file behaviors above the delete record behavior.

Sign in to reply to this post

robert254422

That did it...

Sorry for the late response... To make the thread complete though... changing the order of the code did the trick...

TYVM!

Sign in to reply to this post

bjgarner241692

I have the same issue. Delete File behaviours are before the delete record. Record deletes, but not files. Full page code is below.

Sign in to reply to this post

Jason ByrnesWebAssist

the WADAs_applications recordset that you are using to return the file name and folder name is not filtered.

create another recordset to query the s_applications table, set this recordset to filter the aID on the WADADeleteRecordID form element, and use that recordset in the delete behaviors for the file and folder name settings.

Sign in to reply to this post

bjgarner241692

Thanks. That seems to get me closer but no I am getting an unlink error. I know for certain that the permissions on the folder are correct so that leads me to believe that I am still pointing somehow to the wrong folder.

How can I see where the code is pointing?
ie: I want to do something like this:

php:
<?php echo "../apps/".$row_deleterecord['lname']  ."""".$row_deleterecord['resume']  ."";?>


although that does not work, I am hoping you get the idea.

Sign in to reply to this post

Jason ByrnesWebAssist

The error should have the path it is trying to look at.

or you could use:

<?php echo "../apps/".$row_deleterecord['lname'] ."/".$row_deleterecord['resume'] ."";?>

to write the path.

Sign in to reply to this post

bjgarner241692

I cannot use the Form value, I suspect because nothing is being posted.
I created a recordset using the aID value from the main recordset as the parameter. I inserted the recordset within the repeat region and can successfully show the correct path and filename for each row. I can even link the associated files.
Still though, when I click delete, it deletes the record, but not the files.

Sign in to reply to this post

Jason ByrnesWebAssist

regardless of weather you can write the file names to the page at page load, the values are not sent when the delete button is pressed.

only the WADADeleteRecordID for element is passed when the delete button is pressed.

so you need to use the secondary recordset like i suggested before, and use the secondary recordset i nthe delette behavior.

In the code you paste above, I don't see any delete file behaviors, nor do I see the secondary recordset.

Sign in to reply to this post

bjgarner241692

Recordset is at line 439
Behaviour is at 131
You are correct, delete behaviour was missing. I copied the wrong file.
Zip is attached.
I have tried the same thing using WADADeleteRecordID but it did not work then either. I was using $POST['WADADeleteRecordID'] in the parameter.

Attached Files
s_applications_results.zip
Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...