We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Forms

Dropbox for file uploads

Is it possible to use dropbox as a standard file bucket for form file uploads, rather than just for backups? Don't need to access the assets again, its just a delivery system to the client.

Rob Saunders

Rob Saunders 0 points

  • 1 year ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, I think that might work.

Ive set up as so but no files are arriving in the dropbox folder: runway.php:

    'dropbox' => [

            'access_token' => 'my_token',
            'handler'      => 'PerchDropbox_ResourceBucket',
            'handler_path' => PERCH_CORE.'/runway/apps/perch_dropbox/PerchDropbox_ResourceBucket.class.php',

        ],

buckets.php

<?php
  return [
         'dropbox' => [
                  'type'      => 'dropbox',
                  'web_path'  => '',
                  'file_path' => 'hires',
          ],
     ];
?>

form template:

<perch:form id="documents" method="post" app="perch_forms" action="/hires/account#documents">
     <perch:input id="proofIdentity" type="file" label="Identity Document" bucket="dropbox" accept="image pdf doc text richtext xml zip office" required order="3">
</perch:form>

<div class="account__member__button">
            <perch:input type="submit" value="Upload" class="btn btn--white" />
          </div>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Is the configuration working ok for backups?

Yep backups are working fine

Would it have anything to do with running it locally via MAMP? Backups are working fine locally but can't get anything to come through via the file field type. Slightly frustrating as this was one of the main reasons for updating to Runway as the client wanted file delivery direct to dropbox.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Have you checked your error log and so on? We'll need more information about what actually isn't working to be able to help.

Here is the error log on submission of the form, it seems the file save location is not set? There are some other errors in there with regards to my other post: http://forum.grabaperch.com/forum/06-11-2018-members-account-with-associated-file-uploads

Debug Message - Perch Runway 3.1.1
[32] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate, pr.routeOrder, s.settingValue AS siteOffline FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID LEFT JOIN perch2_settings s ON s.settingID='siteOffline' UNION SELECT NULL AS pagePath, pr2.routePattern, pr2.routeRegExp, pr2.templatePath AS pageTemplate, pr2.routeOrder, NULL AS siteOffline FROM perch2_page_routes pr2 WHERE templateID!=0 ORDER BY routeOrder ASC, pagePath ASC
Matched route: hires/account
Using master page: /templates/pages/hires/account.php
Page arguments:
Array
(
    [0] => /hires/account
)
[1] SELECT * FROM perch2_members_sessions WHERE sessionID='05d1d62d2b2fbe990996ae0b37a71cf5479356ee' AND sessionHttpFootprint='0257b6799cab16c9907fb5efd3ac423e8d7af95f' AND sessionExpires>'2018-06-17 07:17:26' LIMIT 1
User is logged in
[1] SELECT * FROM perch2_pages WHERE pagePath='/hires/account.php' LIMIT 1
[1] SELECT * FROM perch2_shop_cart WHERE cartID=1
[1] SELECT * FROM perch2_shop_cart WHERE cartID=1
[47] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
[nil] SELECT * FROM perch2_shop_sales WHERE saleFrom<='2018-06-17 07:17:00' AND saleTo>'2018-06-17 07:17:00' AND saleActive=1 AND saleDeleted IS NULL ORDER BY saleOrder ASC
[1] SELECT * FROM perch2_forms WHERE formKey='documents' LIMIT 1
Array
(
    [fields] => Array
        (
        )

    [files] => Array
        (
        )

    [page] => Array
        (
            [id] => 20
            [title] => Account
            [path] => /hires/account.php
            [navtext] => Account
        )

)
Form documents: File save location not set, files discarded.
INSERT INTO perch2_forms_responses(responseJSON,formID,responseIP,responseSpamData) VALUES('{\"fields\":{\"first_name\":{\"attributes\":{\"type\":\"hidden\",\"id\":\"first_name\",\"label\":\"First Name\",\"value\":\"<perch:forms id=\"},\"value\":\"Robert\"},\"second_name\":{\"attributes\":{\"type\":\"hidden\",\"id\":\"second_name\",\"label\":\"Second Name\",\"value\":\"<perch:forms id=\"},\"value\":\"Saunders\"},\"identityType\":{\"attributes\":{\"type\":\"select\",\"options\":\"Utility Bill,Something else\",\"id\":\"identityType\",\"label\":\"Identity Document Type\",\"required\":true,\"placeholder\":\"Which proof of identity document are you uploading? (please select)\",\"class\":\"account__member__field__input account__member__field__input--select\",\"order\":\"1\"},\"value\":\"Utility Bill\"},\"identityExpiry\":{\"attributes\":{\"type\":\"date\",\"id\":\"identityExpiry\",\"label\":\"Identity Expiry Date\",\"required\":true,\"class\":\"account__member__field__input account__member__field__input--select\",\"order\":\"2\"},\"value\":\"2018-06-08\"},\"addressType\":{\"attributes\":{\"type\":\"select\",\"options\":\"Utility Bill,Something else\",\"id\":\"addressType\",\"label\":\"Address Document Type\",\"required\":true,\"placeholder\":\"Which proof of address document are you uploading? (please select)\",\"class\":\"account__member__field__input account__member__field__input--select\",\"order\":\"4\"},\"value\":\"Utility Bill\"},\"addressExpiry\":{\"attributes\":{\"type\":\"date\",\"id\":\"addressExpiry\",\"label\":\"Address Document Date\",\"required\":true,\"class\":\"account__member__field__input account__member__field__input--select\",\"order\":\"5\"},\"value\":\"2018-06-21\"},\"insuranceExpiry\":{\"attributes\":{\"type\":\"date\",\"id\":\"insuranceExpiry\",\"label\":\"Insurance Expiry Date\",\"placeholder\":\"Select Date\",\"required\":true,\"class\":\"account__member__field__input account__member__field__input--select\",\"order\":\"7\"},\"value\":\"2018-06-21\"}},\"files\":[],\"page\":{\"id\":\"20\",\"title\":\"Account\",\"path\":\"\\/hires\\/account.php\",\"navtext\":\"Account\"}}','3','::1','{\"fields\":[],\"environment\":{\"REDIRECT_HTTPS\":\"on\",\"REDIRECT_SSL_TLS_SNI\":\"dev.floatingharbour.co.uk\",\"REDIRECT_STATUS\":\"200\",\"HTTPS\":\"on\",\"SSL_TLS_SNI\":\"dev.floatingharbour.co.uk\",\"SSL_SERVER_S_DN_CN\":\"dev.floatingharbour.co.uk\",\"SSL_SERVER_I_DN_CN\":\"dev.floatingharbour.co.uk\",\"SSL_VERSION_INTERFACE\":\"mod_ssl\\/2.2.29\",\"SSL_VERSION_LIBRARY\":\"OpenSSL\\/0.9.8zh\",\"SSL_PROTOCOL\":\"TLSv1\",\"SSL_SECURE_RENEG\":\"true\",\"SSL_COMPRESS_METHOD\":\"NULL\",\"SSL_CIPHER\":\"AES128-SHA\",\"SSL_CIPHER_EXPORT\":\"false\",\"SSL_CIPHER_USEKEYSIZE\":\"128\",\"SSL_CIPHER_ALGKEYSIZE\":\"128\",\"SSL_CLIENT_VERIFY\":\"NONE\",\"SSL_SERVER_M_VERSION\":\"1\",\"SSL_SERVER_M_SERIAL\":\"AA64515CD8A54171\",\"SSL_SERVER_V_START\":\"Sep 13 11:32:07 2017 GMT\",\"SSL_SERVER_V_END\":\"Sep 11 11:32:07 2027 GMT\",\"SSL_SERVER_S_DN\":\"\\/CN=dev.floatingharbour.co.uk\",\"SSL_SERVER_I_DN\":\"\\/CN=dev.floatingharbour.co.uk\",\"SSL_SERVER_A_KEY\":\"rsaEncryption\",\"SSL_SERVER_A_SIG\":\"sha1WithRSAEncryption\",\"SSL_SESSION_ID\":\"6BD794C1D39D696E50B70CAFF6F75C9C549541D00C14EC1C1685ECA39E98A0C5\",\"HTTP_HOST\":\"dev.floatingharbour.co.uk\",\"HTTP_CONNECTION\":\"keep-alive\",\"CONTENT_LENGTH\":\"178565\",\"HTTP_CACHE_CONTROL\":\"max-age=0\",\"HTTP_ORIGIN\":\"https:\\/\\/dev.floatingharbour.co.uk\",\"HTTP_UPGRADE_INSECURE_REQUESTS\":\"1\",\"CONTENT_TYPE\":\"multipart\\/form-data; boundary=----WebKitFormBoundary6L9bOFXCw50TPRPD\",\"HTTP_USER_AGENT\":\"Mozilla\\/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/66.0.3359.181 Safari\\/537.36\",\"HTTP_ACCEPT\":\"text\\/html,application\\/xhtml+xml,application\\/xml;q=0.9,image\\/webp,image\\/apng,*\\/*;q=0.8\",\"HTTP_REFERER\":\"https:\\/\\/dev.floatingharbour.co.uk\\/hires\\/account\",\"HTTP_ACCEPT_ENCODING\":\"gzip, deflate, br\",\"HTTP_ACCEPT_LANGUAGE\":\"en-US,en;q=0.9,cs;q=0.8\",\"HTTP_COOKIE\":\"_ga=GA1.3.187700209.1486914985; cmsa=1; PHPSESSID=33f942db15553e6513c7e7f51c1d7dd6; p_m=05d1d62d2b2fbe990996ae0b37a71cf5479356ee; _gid=GA1.3.2145239343.1529208610; _gat=1\",\"PATH\":\"\\/usr\\/bin:\\/bin:\\/usr\\/sbin:\\/sbin\",\"SERVER_SIGNATURE\":\"\",\"SERVER_SOFTWARE\":\"Apache\",\"SERVER_NAME\":\"dev.floatingharbour.co.uk\",\"SERVER_ADDR\":\"::1\",\"SERVER_PORT\":\"443\",\"REMOTE_ADDR\":\"::1\",\"DOCUMENT_ROOT\":\"\\/Users\\/Rob\\/Sites\\/floating-harbour-hub\\/build\",\"SERVER_ADMIN\":\"you@example.com\",\"SCRIPT_FILENAME\":\"\\/Users\\/Rob\\/Sites\\/floating-harbour-hub\\/build\\/admin\\/core\\/runway\\/start.php\",\"REMOTE_PORT\":\"49738\",\"REDIRECT_URL\":\"\\/hires\\/account\",\"GATEWAY_INTERFACE\":\"CGI\\/1.1\",\"SERVER_PROTOCOL\":\"HTTP\\/1.1\",\"REQUEST_METHOD\":\"POST\",\"QUERY_STRING\":\"\",\"REQUEST_URI\":\"\\/hires\\/account\",\"SCRIPT_NAME\":\"\\/admin\\/core\\/runway\\/start.php\",\"PHP_SELF\":\"\\/admin\\/core\\/runway\\/start.php\",\"REQUEST_TIME_FLOAT\":1529219846.29,\"REQUEST_TIME\":1529219846,\"argv\":[],\"argc\":0}}')
[1] SELECT * FROM perch2_forms_responses WHERE responseID='98' LIMIT 1
No ids to log.
[2] SELECT * FROM perch2_members ORDER BY memberEmail ASC
Looking up missing property has_tag
SELECT has_tag FROM perch2_members WHERE memberID='20'
[0] Invalid query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'has_tag' in 'field list'
Looking up missing property has_tag
SELECT has_tag FROM perch2_members WHERE memberID='22'
[0] Invalid query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'has_tag' in 'field list'
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
Using sub-template: /templates/pages/attributes/facebook.html
Using sub-template: /templates/pages/attributes/twitter.html
Using cart from cache.
Using template: /templates/shop/cart/cart-mini.html
Using template: /templates/search/search-form.html
[5] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/hires/account.php' OR regionPage='*' ORDER BY regionPage DESC
Using template: /templates/members/forms/profile.html
Using template: /templates/forms/documents.html
<perch:member has-tag="unverified">
PerchXMLTag Object
(
    [attributes] => Array
        (
            [has_tag] => unverified
        )

    [data_attributes] => Array
        (
        )

    [tag:PerchXMLTag:private] => 
)
<perch:form template="/templates/forms/documents.html" id="documents" method="post" app="perch_forms" action="/hires/account#documents"> <perch:input type="hidden" id="first_name" label="First Name" value="Robert"> <perch:input type="hidden" id="second_name" label="Second Name" value="Saunders"> <div class="account__member__documents__section" id="identity"> <h3 class="account__member__documents__title">Proof Of Identity</h3> <div class="account__member__field"> <perch:input type="select" options="Utility Bill,Something else" id="identityType" label="Identity Document Type" required placeholder="Which proof of identity document are you uploading? (please select)" class="account__member__field__input account__member__field__input--select" order="1"> </div><!--/account__member__field--> <div class="account__member__field"> <perch:label for="identityExpiry" class="account__member__field__label">Document Expiry Date:</perch:label> <perch:input type="date" id="identityExpiry" label="Identity Expiry Date" required class="account__member__field__input account__member__field__input--select" order="2"> </div><!--/account__member__field--> <div class="account__member__field"> <perch:input id="proofIdentity" type="file" label="Identity Document" bucket="dropbox" accept="image pdf doc text richtext xml zip office" required order="3"> </div><!--/account__member__field--> </div><!--/account__member__documents__section--> <div class="account__member__documents__section" id="address"> <h3 class="account__member__documents__title">Proof Of Address</h3> <div class="account__member__field"> <perch:input type="select" options="Utility Bill,Something else" id="addressType" label="Address Document Type" required placeholder="Which proof of address document are you uploading? (please select)" class="account__member__field__input account__member__field__input--select" order="4"> </div><!--/account__member__field--> <div class="account__member__field"> <perch:label for="addressExpiry" class="account__member__field__label">Document Expiry Date:</perch:label> <perch:input type="date" id="addressExpiry" label="Address Document Date" required class="account__member__field__input account__member__field__input--select" order="5"> </div><!--/account__member__field--> <div class="account__member__field"> <perch:input id="proofAddress" type="file" label="Address Document" bucket="dropbox" accept="image pdf doc text richtext xml zip office" required order="6"> </div><!--/account__member__field--> </div><!--/account__member__documents__section--> <div class="account__member__documents__section" id="insurance"> <h3 class="account__member__documents__title">Insurance Document</h3> <div class="account__member__field"> <perch:label for="insuranceExpiry" class="account__member__field__label">Document Expiry Date:</perch:label> <perch:input type="date" id="insuranceExpiry" label="Insurance Expiry Date" placeholder="Select Date" required class="account__member__field__input account__member__field__input--select" order="7"> </div><!--/account__member__field--> <div class="account__member__field"> <perch:input id="insuranceDocument" type="file" label="Insurance Document" bucket="dropbox" accept="image pdf doc text richtext xml zip office" required order="8"> </div><!--/account__member__field--> </div><!--/account__member__documents__section--> <div class="account__member__button"> <perch:input type="submit" value="Upload" class="btn btn--white" /> </div> <perch:success> <div class="account__member__documents__section"> <h3 class="account__member__documents__title">Proof Of Identity</h3> <div class="account__member__verified"> <img class="account__member__verified__document" src="/a/img/hires/file.png" alt="file" /> <p class="account__member__verified__text">Thank you for uploading, awaiting verification.</p> </div><!--/account__member__verified--> </div><!--/account__member__documents__section--> <div class="account__member__documents__section"> <h3 class="account__member__documents__title">Proof Of Address</h3> <div class="account__member__verified"> <img class="account__member__verified__document" src="/a/img/hires/file.png" alt="file" /> <p class="account__member__verified__text">Thank you for uploading, awaiting verification.</p> </div><!--/account__member__verified--> </div><!--/account__member__documents__section--> <div class="account__member__documents__section" id="insurance"> <h3 class="account__member__documents__title">Insurance Document</h3> <div class="account__member__verified"> <img class="account__member__verified__document" src="/a/img/hires/file.png" alt="file" /> <p class="account__member__verified__text">Thank you for uploading, awaiting verification.</p> </div><!--/account__member__verified--> </div><!--/account__member__documents__section--> </perch:success> </perch:form> <perch:else:member> <div class="account__member__documents__section"> <h3 class="account__member__documents__title">Proof Of Identity</h3> <div class="account__member__verified"> <img class="account__member__verified__document" src="/a/img/hires/file.png" alt="file" /> <p class="account__member__verified__text">Document verified, thank you very much!</p> <img class="account__member__verified__tick" src="/a/img/hires/tick.png" alt="tick" /> </div><!--/account__member__verified--> </div><!--/account__member__documents__section--> <div class="account__member__documents__section"> <h3 class="account__member__documents__title">Proof Of Address</h3> <div class="account__member__verified"> <img class="account__member__verified__document" src="/a/img/hires/file.png" alt="file" /> <p class="account__member__verified__text">Document verified, thank you very much!</p> <img class="account__member__verified__tick" src="/a/img/hires/tick.png" alt="tick" /> </div><!--/account__member__verified--> </div><!--/account__member__documents__section--> <div class="account__member__documents__section" id="insurance"> <h3 class="account__member__documents__title">Insurance Document</h3> <div class="account__member__verified"> <img class="account__member__verified__document" src="/a/img/hires/file.png" alt="file" /> <p class="account__member__verified__text">Document verified, thank you very much!</p> <img class="account__member__verified__tick" src="/a/img/hires/tick.png" alt="tick" /> </div><!--/account__member__verified--> </div><!--/account__member__documents__section-->
Request time: 0.145
Process time: 0.1384
Memory: 5.4379

What should go in the file upload path within the form options? Normally I would put the file path here but not sure what is required for dropbox?

Rachel does that error log help at all? Would like to get this working asap if possible.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I think you probably want to set it to something like:

dropbox://hires

That returns the following error:

Warning: is_writable(): Unable to find the wrapper "dropbox" - did you forget to enable it when you configured PHP? in /Users/Rob/Sites/floating-harbour-hub/build/admin/addons/apps/perch_forms/modes/form.settings.post.php on line 27

along with: The file path dropbox://hires is not writable by PHP.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Hmm, ok. Create this file:

/admin/addons/apps/saunders_dropbox/runtime.php

Put this in it:

<?php 
$Bucket = PerchResourceBuckets::get('dropbox');
$Bucket->initialise();

and then in your config/apps.php add this to the array:

'saunders_dropbox'

Awesome, thats sorted it thank you very much. Still getting that error message in the form settings but the files are arriving in dropbox.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Copy your runtime.php as admin.php and that might also fix the control panel warning.