Download file on your website - phrase
Download file on your website - really. And
Apply file upload or download
Universal Email 4 has all the file manipulation functionality previously included in Digital File Pro. This functionality allows you to apply file upload behaviors, file download behaviors, and the ability to delete or rename files from your server. It is now included in the Data Bridge bundle.
This tutorial runs you through using the File Upload and File Download functionality found in Universal Email.
- Dreamweaver CS3 or later
- Universal Email 4
- PHP page
- Database connection (required for counter in digital download section)
Universal Email's File Upload behavior is the most common of the File Manipulation features found in this extension. Here you can specify upload restrictions, determine where the file is stored, and what file types can be uploaded.
Step 1: Create the File field
Your PHP page must have a file field to allow the user to browse for a file to be uploaded. Follow these steps to add a form field to your page, or use CSS Form Builder to create a form that contains a file field prior to continuing with this tutorial.
- With your dynamic page already open, choose the File field option from Forms category of the Insert bar.
- In the ID field enter 'upload'.
- In the Label field enter 'Upload File'.
- These are recommended IDs and Labels, feel free to specify something different.
- Click OK.
- If your cursor was not already within a form tag, you will be asked to create one. Click Yes in this case.
- Place your cursor below the File field to create a Submit button.You can create as many form fields as you like. Here we will just cover the single Upload field.
- From the Insert menu, choose Form > Button.
- In the ID field enter 'submit'.
- Leave the Label field blank.
- Click OK.
- Press Ctrl (Cmd) S to save your page.
Once you have created a file field on your PHP page, you can apply the Upload behavior.
- From the Insert menu choose WebAssist > File Manipulation > Upload.
- From the Trigger menu, choose Button: Submit pressed.
- From the File Field menu, choose the File field, upload, that we just created.Many of the options available in the wizard can be configured dynamically. Look for the lightning bolt if wish to dynamically configure an option.
- If you wish to only allow images to be uploaded, choose the Web images only checkbox.
This will enable a number of image resize options in Step 2 of the wizard. - If Web images only is selected, choose a file format that you wish to convert all images. If you choose JPEG or PNG, set the desired level of quality or compression, respectively, from the adjacent list.
If you do not wish to convert the image format, choose Keep existing format. - From the Action menu, choose what you wish to be done to a file if a file with the same filename is already on the server.
- If a Rename option is selected in the Action menu, choose how you wish to rename the file.
- By default, the name will be appended with a number.
- Click Next to proceed to Step 2.
Step 1: Using the File Settings Window
The File settings window allows you to specify multiple output options for the file that is being uploaded. By default, only one file is saved.
- To add an additional file to be outputted, choose the Add ( + ) icon.
- Select the new file entry in the File Settings window, to specify settings for that file.
- In the Upload folder field, enter the relative path to the folder you wish the file to be uploaded to.
- In the File field, enter the filename you wish this file to have. Use '[FileName]' if you want to keep the original name.
- If necessary, in the Default file field, enter a file to be used as placeholder for this image.
Step 2: Customizing Image options
The Image options settings will be available if Web images only was selected in Step 1 of the wizard.
- From the Resize menu, choose the resize option (if any) that you wish to apply to this image.By default, if you have selected to add a second item to the File Settings window, this option will automatically have been configured for a the creation of a thumbnail image. These settings are simply recommended for easy implementation, feel free to change them at any time. You can specify these default values by choosing Edit > WebAssist Preferences and selecting the Digital File Pro category.
- Specify a width and height for your settings Depending on your selection from the Resize menu, these options may not be available.
- Choose a fill color from the Fill color menu.
This option is only available when the Fixed width and height option is selected in the Resize menu. - Click Finish to apply this behavior to your page.Remember, if your form action="", then your form is submitting to its own page. In this case, when you preview your page in a browser, upload a file and click submit, the page will just reload and the browser will display a message that no file is selected. You can test that your upload is working by looking inside of the folder you specified in the upload server behavior.
Step 3: Add a progress bar
Universal Email 4 includes the ability to add a progress bar that will display while an upload is in progress. For instructions on adding a progress bar to your form, check out the Add a Progress Bar tutorial.
The File Manipulation features include the ability to add secure download features to your site as well. If you are selling digital goods, or want to restrict access to downloading certain files on your web site, this can be very useful.
There are a number of practical uses for this capability, and each varies based on your needs.
The following details the basic steps for applying the download server behavior to a button.
Step 1: Create the Download button
- Place your cursor on your dynamic page, where you want to add the download button.
- From the Forms category of the Insert bar, choose Button.
- In the ID field, enter download.
- Leave the Label field blank.
- Click OK.
- Click once to select your new button.
- In the Properties Inspector enter Download in the Value field.
Step 2: Create the Download behavior
- From the Insert menu, choose WebAssist > File Manipulation > Download.
- From the Trigger menu, choose Button: download pressed.
- In the Folder field, specify the directory that stores the file that is to be downloaded.
- From the File name menu, enter the name of the file to be downloaded.
- In the Save as field, enter the file name you wish the downloaded file to have.
With this feature, you can have a complicated file name that conforms to your file storage requirements, but can choose a friendlier file name for the customer who downloads the file.
In the Download counter section, you can specify details for tracking how many times an individual file has been downloaded. You may find this useful for tracking purposes, but also if you have restrictions on how many times an individual can download a particular file.In order to use this feature, you must already have created a connection to a database that contains a column for storing the download count. - From the Connection menu, choose the database connection you wish to use.
- From the Table menu, choose the database table to be used.
- From the Key column menu, select the key column for the table you selected.
- From the Key column value menu, choose the value in the key column that applies to the file that is being downloaded.
In most cases, you first want to have a database table for your Items (or downloads) where there would be an entry for this particular item. This would also allow you to create more advanced dynamic options for your download - From the Count column menu, choose the database column you wish to use to store the count value.
- When you are ready, click OK.
- Press Ctrl (Cmd) S to save your page.
- Press F12 to preview and test your download.
- Click the download button to download the file, and check your database to see if the download was recorded.
If you want to customize success and error messages, view this tutorial.
-
-