PHP in Ajax to delete a file in an upload folder

If I read the Fileupload value of an element it carries the path and the filename.

If i read that path/filename into $myfile:

What is the PHP syntax that I can use to kill the file &myfile?

Some googling points to an unlink() function but it comes with so many warnings that i am now scared to just stick it in.

Once I get this working I will publish this into a thread for any desperados like me that could not wait for a formal cancel/unload functionality.

Deperately needed in my opinion...
 
So you want to delete the physical file and the reference that the record points to but to keep the existing record?
 
Hi Felixkat, long time no "see"

Yes, to make it easier for my procurement department I have one record (for the invitation) and the Vendor must upload 5 documents that will be verified before qualifying to download the tender information (which sits on another table)

Cheesegrits responded at one stage to say there is no way to "cancel" an upload, so I created my own workaround (that works) using the Fabrik-Java to .js(function) - ajax_pho(function) where I have an update query to clear the file upload field from a button labelled "Cancel Upload". That works but obviously the file is now still in the folder.
in the user_ajax I want to add the following:
I want store the file reference into a variable called say $cancelledfilename before I proceed with the update/clear query then at the end delete the file as well as the $cancelledfilename will know the filename and where it is stored.
 
I have found that bumping to maintain a "page 1" status really doesn't gain you anything here. There are many users here that will respond fairly quickly if they think they can help. Rob and Hugh are pretty good about a FIFO policy when they go through threads even when things are backed up. Bumping after 2-3 days is a good idea though as things do slip through.
 
Well you were on Page 2 today, but I did look for you. :)

I spoke briefly to Hugh about this last night and discovered something I didn't know myself.

If you have an Ajax fileupload and you are editing a record you will see a list of previously uploaded files. If you click the 'green tick' to the right of the file it deletes that record and removed it from the database. :)

Now I think it would probably nicer if we had maybe a tick and a cross.... but that's how it is at the moment.

By the way the actual code that is being used for the ajax fileuploader is pupload which is over here. http://www.plupload.com/ Their forums are full of tweaks and requests and code changes so if you see anything really useful it maybe something we can implement.

Bear in mind though that even with example code on their forums it may not be a 2 minute job with Fabrik so any feature requests would have to be logged through Github as with other requests.
 
Hi Rackem, I appreciate that but I only bump if I am still battling away and in my state of mind I do feel that being on page 1 will get someone to read it.

Felixkat, I do not quite know what this means but I will now try and find out what this means ...
 
Ok, I may have given you the wrong information. As you were throwing the word Ajax in I thought you were talking about the ajax file upload not the standard file upload.

So in this case we don't currently have a way of deleting files but Hugh has raised a feature request on this one.

in the user_ajax I want to add the following:
I want store the file reference into a variable called say $cancelledfilename before I proceed with the update/clear query then at the end delete the file as well as the $cancelledfilename will know the filename and where it is stored.

So you really need a delete existing upload opposed to cancel upload. I'm trying not to be picky on the termonology if I don't I get confused.... ;)

So yes you need to identify the element you are clicking, lookup the file reference and remove the physical file from disk. Theoretically you don't need to update the database as this would happen as soon as you upload a new file.... however it should be done for completeness, as things could get messy.

Hugh has done a feature request so we just need to brain storm a little the best way of coding this.

https://github.com/Fabrik/fabrik/issues/534
 
I want to know how to programaticaly change the label of the ANY field, Once I know the syntax I can stick it on any other event to change labels

I now have the FileUpload element (which still does not show the filename) and a button that I want to use to delete/cancel the link. In other VB applications I use the label on a button to to indicate what I want the user to do.

So on load I want "read in" the filename using JAVA->.JS function-User_Ajax function(Query) return the value upstream and display ON the button. I could use a read only extra field for this but I do not want to clutter up the form any more as I already have to provide a button for each upload field.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top