Custom Uploader
From Shup
The custom uploader allows you to upload files to your own webserver. Before you can upload files to your webserver using Shup, some configuration is required. Below are some step by step instructions to get you up and running.
Contents |
Webserver and Upload Script Configuration
Your webserver must host an upload script that can receive files from Shup. The upload script must produce an XML response in a format that Shup can read. When you install Shup, an example script called custom_uploader_example.phps is stored in the Shup install directory. To configure your webserver to accept uploaded files from Shup, perform the following steps:
1. Copy custom_uploader_example.phps file to a file called upload.php.
2. Edit the upload.php:
- The $my_local_path variable must be set to the local path where the images will be uploaded. For example:
- $my_local_path = "/var/www/html/shupFiles/";
- The $my_web_root variable must be set to the URL where the images will be stored. For example:
- $my_web_root = "http://whydoesmycat.com/shupFiles/";
3. Copy your upload.php file to your webserver. Note: The example custom uploader script (custom_uploader_example.phps) does not implement file size limitations, file type limitations, or other security implementations. We recommend that you implement the security features that you require.
Testing the Upload Script Using HTML
It is a good idea to test your script with a basic HTML form prior to configuring and testing your script with Shup. However, you can skip this section if you feel strongly that your upload script is working properly. Testing your script using an HTML form will allow you to see the XML response that is produced by your upload script. The XML response must be in the format that Shup can understand. To test your upload script using HTML, perform the following steps:
1. Create a test page, called uploadform.html, containing the following text
- <html>
- <body>
- <form method="POST" action="./upload.php" enctype="multipart/form-data">
- <input type="file" name="file" style="width: 340px;" size="39" />
- <input type="submit" value="Upload" />
- </form>
- </body>
- </html>
2. Upload the uploadform.html file to the same location on your webserver that you copied upload.php.
3. Open the test page using your browser and attempt to upload a file. The resulting page may contain a message saying that the XML file does not contain any style information - that's alright. If you view the source of the page, it should look like this:
- <upload><url>http://whydoesmycat.com/shupFiles/test.jpg</url><filename>test.jpg</filename></upload>
It is OK if there is extra whitespace in the file, but it is crucial that the file contains the syntax in the example above. Otherwise, your file may upload with the HTML form, but it will not upload successfully using Shup.
4. Check the shupFiles directory on your webserver to ensure the file uploaded successfully. If your file did not upload successfully, try the following steps to troubleshoot:
Trouleshooting
- Ensure that your webserver is capable of running PHP files.
- Ensure that the permissions on your webserver are set so that files can be added to the shupFiles directory.
- Ensure that the file name parameter in the HTML form is the same as the $file variable in the upload script. In the examples above, we set both to file.
Shup Configuration
After you have setup your webserver to accept files, Shup configuration is easy!
1. Open Shup and click File > Preferences. The Shup Preferences window appears.
2. Click File Uploading and Network.
3. Select Custom Uploader (your server) from the list of uploaders.
4. Click the Configure Selected Uploader button. The Shup Custom Uploader Configuration window appears.
5. Select Add new profile... from the Choose a site profile... drop-down list.
6. Enter the following information in the fields on the screen:
- Profile Name: Defines the name for your new profile. You can set this to anything you want.
- Form File Input: Defines the value that you specified for the $file variable in your upload script. In our examples, we used file
- Receiving URL: Defines the URL that points to your upload script. The script must be accessible from the computer in which you are running Shup.
For example:
- Profile Name: whydoesmycat.com webserver
- Form File Input: file
- Receiving URL: http://whydoesmycat.com/shupFiles/upload.php
7. Click the Save Changes button.
8. Select your new profile from the drop down list, and click the Set as Active Profile button.
Congratulations! You should now be able to upload files to your webserver using Shup.
If you receive an error while uploading files to your webserver using Shup, try the following troubleshooting steps:
Troubleshooting
- Refer to the Testing the Upload Script Using HTML section to make sure your upload script is working with a basic HTML page.
- Ensure that the Form File Input setting on the Shup Custom Uploader Configuration screen is set to the same value that is specified for the $file variable in your custom uploader script.
- Ensure that your profile is set as the active profile (on the Shup Custom Uploader Configuration screen). The active profile is displayed in the drop-down list with a star beside it.
- Ensure that the value you specified for the Receiving URL (on the Shup Custom Uploader Configuration screen) is a valid URL. To verify this, try pasting the URL into your browser. You should receive a Shup formatted XML response that says No data was submitted (if you are using the example custom uploader script). Check to make sure that the XML document is in the format that is understood by Shup.
