This document walks you through posting a form with a file payload from a Zesty.io website to a remote PHP server that will capture the information, store the file to a temporary directory, and return back to the Zesty.io website. This tutorial expects you to have a Zesty.io site ready to work in, and have roughly 10-20 minutes to test from start to finish.
10-20 minute start to finish
We have set up a simple example that leverages a free server on Heroku which deploys a codebase from Github. It will capture a Zesty.io Form post and store information locally, then return to a website thank you page . To get started you need a Heroku account, it is free and only take a few minutes to create.
If you already have a Heroku account, proceed to click the button below. If you do not have an account, create one here, then click the Depoly to Heroku button below.
That button will open a Heroku prompt to create a new server using this PHP repository we created for this tutorial: Example Post File Capture Project for PHP. When you are done with this tutorial you may fork this repository and customize it to suit your needs. In the Heroku prompt, it will asks for config variables, paste your thank you page url (https://www.your-website.com/thank-you/) and your file size limit FILE_SIZE_LIMIT
After clicking deploy, you will see two buttons
manage app and
manage app. It will open a dashboard with six menu items. The last one is
settings, click settings. Scroll down to domains, and copy the Heroku Domain provided.
Take your copied Heroku domain from step 3 and prepend
https:// to it and append
/submission. The full URL should look something like this:
https://zesty-php-file-capture-test.herokuapp.com/submission. This is the URL you will put in the form action parameter on the
Example form HTML Form code to put on your Zesty.io template in the Code Editor:
Save in Zesty.io, goto the page in Zesty.io's live preview, and Submit a form. Depending on your file size and internet connection, the time may vary before the page return to the thank you call back. You can verify the file uploaded by visting your Heroku domain
https://zesty-php-file-capture-test.herokuapp.com/list.php as that will show you files uploaded. Note, every time to redeploy the Heroku site, all files will be wiped out. From here you pass the files to your favorite storage service like AWS S3 or Dropbox.
You just successfully connected Zesty.io to your own custom PHP server hosted on Heroku. Congratulations, you all star! Being able to network applications together allows you to maximize the benefits of each application without running into the security or update risks that occur when you customize a softwares codebase!
If you wish to modify the codebase you deployed to Heroku, start by checking out the Github Repo example we used: https://github.com/zesty-io/example-form-file-post-with-return-php the two files you should be most interested in are
/public/index.php in the
/public/ directory, and
/public/list.php file in the
index.php does all the heavy lifting of accepting the payload and saving the file to the server's
list.php is there to verify your file uploads are working.
You can Fork the https://github.com/zesty-io/example-form-file-post-with-return-php, hook it up to Heroku or your own server, are start making changes to connect to any service you wish.
© Copyright 2010-2019 Zesty.io Platform, Inc. All Rights Reserved.