Silent Remote POST doesn't send files
-
Hi
I would like to send post data to a php file so that I insert it to my DB. I am not using CFDB because it only inserts to the WordPress DB. I have a different DB I want to insert to.
When I use silent post, all data comes through including the name of the file attached. This comes as a string, “File attached is: picture.png”
I want to use:
file_get_contents($_FILES["fileToUpload"]["tmp_name"]);
to get the file contents and convert to base64 before I insert.
Question: Can I adjust the post function so that I can receive the file instead of a string?
Can I adjust the form to convert the file to base64 and post that to my remote url as a string?
Is their any other way to get the uploaded image to my DB? example is it possible to store the filename on the db and retrieve its content through php?Mark
-
There is a do action hook ‘fsctf_mail_sent’ for adding your own custom action for after the email is sent.
When the hook fires, the attachments are still on the server, they get deleted promptly afterhttp://www.fastsecurecontactform.com/do-action-hook-for-mail-sent
I have tried the do action hook.
=>$valuedisplays all posted data as a string. I receiveFile is attached: pictiure.png
I would like to use
file_get_contents($_FILES["fileToUpload"]["tmp_name"]);to get the file contents and convert to base64.
Question: Can I retrieve file contents in php before its deleted from the server?
II: how come all data posted is in string? I would much rather receive the url of the picture’s location on the server rather than “file is attached…..”Mark
Normally the program attaches the file to the email and then deletes it.
if you do not want it deleted check this setting on the advanced settings tab “Enable to not delete email attachments from the server”
They will stay in the /plugins/si-contact-form/attachments folder until you delete them. Note: use this feature at your own risk, because storing the files there could potentially expose privacy if the files uploaded contain private information.When the do action hook ‘fsctf_mail_sent’ fires, the uploaded files are in this folder
/wp-content/plugins/si-contact-form/attachments/If the uploaded file was
picture.pngWhen you run your own custom php function using the do action hook, you can copy it from this folder and get the file contents and convert to base64 as you wish. After the form submit is completed, it does delete the uploaded files.
/wp-content/plugins/si-contact-form/attachments/picture.png
You might be able to access the uploaded files like this:
if ( ! empty(self::$uploaded_files) ) { //attachment temp files foreach ( (array) self::$uploaded_files as $path ) { // do whatever you want to the file $path } }Thanks for the attachments url, which I am extracting the file directly from.
file_get_contents("../../apps/wordpress/htdocs/wp-content/plugins/si-contact-form/attachments/$pic_name", true);I know its barbaric but I’m looking for a better way to do this.
I haven’t been able to get the file using your code snippet though… Would I place this code in the theme’s functions.php file? isself::$uploaded_filesa variable within this class? I imagine the error is that php cannot find the variable $uploaded_files. Is there something av missed? kindly expound..Interestingly though, the files on the attachments folder are left on the server even if I disable the option Enable to not delete email attachments from the server
Mark
The topic ‘Silent Remote POST doesn't send files’ is closed to new replies.