Reputation: 305
I am trying to save user data while on later i give the option to user to see his unsaved work.I got all the data but image upload file is missing.I i am trying to save file field like this in DB :
$files = $_FILES;
$__fields['file'] = json_encode($files);
Then i save this field to DB.I tried to set the file field like this but no luck.
$files = json_decode($row['file']);
jQuery('#myimg'). val('<?php echo $files->name;?>');
what i am doing wrong ? I want that when customer see his unsaved data the file field is filled like he leaved it.Only file field is creating issue for me.Thanks
Upvotes: 0
Views: 71
Reputation: 543
When a user unsaved a file means he doesn't uploaded to your server. the file is being in his local computer. And Its not possible to take that it from php side. unless you upload the file.
Do one thing when the user select file then upload it to your server and keep it in a temporary place and then do your job. hope this helps
Upvotes: 3
Reputation: 11365
As per the documentation, $_FILES
is an associative array of items uploaded to the current script via the HTTP POST method. See manual
What you need to do;
$_FILES
on the initial HTTP POST.See http://www.w3schools.com/php/php_file_upload.asp
(sorry for a w3schools link)
Upvotes: 3