Delete specific Image File when uploading new images.
This is hard to explain so please hang in there!!
Ok I have a form that is allowing users to upload a total of 12 images, the images upload to a specified folder and data is inserted into the database. Users can re-upload any of the 12 images they want so for example they can choose to replace image 3, 5 & 7 buy clicking the upload file and then clicking the upload button, the files are then replaced on the server and the name is exactly the same, this works like a charm.
What I have also done is created an image cropping section where users can click any of the 12 images they've uploaded and this will then alow them to crop a section of the image and this then saves a new photo to the server called img1-cropped.jpg
Still with me!!
What I really need to do is get the update page to delete any of these cropped images from the server when a new photo is uploaded, so for example, if i upload a new photo to replace image1.jpg I need the form to remove img1-cropped.jpg during the same process. This so when the user view the crop image page they don't see the wrong (old) image anymore.
I though i cracked it by including:
$WA_DeleteFileResult2 = WA_FileAssist_DeleteFile("../../assets/uploads/events/images/", "".$row_DLA_Event['ID'] ."img12-cropped.jpg");
Within the WA_DFP_SetupUploadStatusStruct command, it works BUT it removes every cropped image even if i only upload one new photo, here is the small code block i used.
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult2");
if(isset($_POST["submit_x"])){
WA_DFP_UploadFiles("WA_UploadResult2", "new_img1", "0", "", "JPG:70", $WA_UploadResult2_Params);
$WA_DeleteFileResult2 = WA_FileAssist_DeleteFile("../../assets/uploads/events/images/", "".$row_DLA_Event['ID'] ."img1-cropped.jpg");
}
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult3");
if(isset($_POST["submit_x"])){
WA_DFP_UploadFiles("WA_UploadResult3", "new_img2", "0", "", "JPG:70", $WA_UploadResult3_Params);
$WA_DeleteFileResult2 = WA_FileAssist_DeleteFile("../../assets/uploads/events/images/", "".$row_DLA_Event['ID'] ."img2-cropped.jpg");
}?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult4");
if(isset($_POST["submit_x"])){
WA_DFP_UploadFiles("WA_UploadResult4", "new_img3", "0", "", "JPG:70", $WA_UploadResult4_Params);
$WA_DeleteFileResult2 = WA_FileAssist_DeleteFile("../../assets/uploads/events/images/", "".$row_DLA_Event['ID'] ."img3-cropped.jpg");
}?>
Do you know how I can achieve this, delete a specific file from the server that matches the relevent image uploaded.
Really hope this makes sense, i've posted quite a few times with different problems throughout the forum without much resolve so am hoping to crack this one.
Thanks
Lee