how to get the value of the id & refresh the data after upload the file
how to get the value of the id & refresh the data after upload the file
In my app. I'll have my user to upload an file with the form. I've downloaded the file upload plug-in and put it into my codes. But I dont' know how to send the id value to the server too. After the user uploading the file, the filename should be updated into the database.
This discussion has been closed.
Answers
The following is what I do:
1. add a hidden filed to the form.
fields : [ {
"name" : "guid",
"type" : "hidden"
}, {
use the following code to get the guid value ( the table key value) for ajax to the server:
var guid = editor.s.fields.guid.s.opts._val;
Then, the server's php can update the table value with the guid key value.
Sounds a bit complicated. You should be able to just have the upload field's value as the primary key id for the file.
Can you show us your PHP and Javascript initialisation code please?
Allan
My PHP:
My Javascript:
The "PHP" looks a bit wrong (it is HTML). Could you update that please?
Allan
The following is all the php code:
All the app is using ur code & ajax:
_data.php-> for data connection;
_function.php-> for php functions
_header.php -> for generate the page header
I use the upload plug-in to upload the file to the server, but I cannot transfer the id key to the server with the post, that's why I add "data.append("guid", guid) " to the code. The guid is the key value of the table record.
If I don't add the guid value manually, the following codes with just upload the file to the server.
So you are not using the Editor
Upload
class on the server side? That would probably explain why it is proving to be a bit more difficult that it should.The
Upload
class is documented here if you did want to try it.Regards,
Allan
No, I don't use the Upload class on the server side, but use my own. I think that should be OK? Is there anything I've missed to send to client side. The following is my server side code for retrieving data: