{"id":10816,"date":"2024-03-14T12:50:34","date_gmt":"2024-03-14T12:50:34","guid":{"rendered":"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/"},"modified":"2025-08-04T04:17:59","modified_gmt":"2025-08-04T04:17:59","slug":"how-can-i-set-the-download-directory-for-files-in-uniapp","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/","title":{"rendered":"Uniapp Download Directory Setup Guide"},"content":{"rendered":"<p>In uniapp, you can specify the file download directory using the uni.downloadFile() method. The specific steps are as follows:<\/p>\n<ol>\n<li>To start, make sure to import the uni.downloadFile() method in your Uniapp page.<\/li>\n<li>Call the uni.downloadFile() method at the place where you need to download the file, and specify the download directory for the file.<\/li>\n<\/ol>\n<p>The example code is as follows:<\/p>\n<pre class=\"post-pre\"><code>uni.<span class=\"hljs-title function_\">downloadFile<\/span>({\r\n  <span class=\"hljs-attr\">url<\/span>: <span class=\"hljs-string\">'http:\/\/example.com\/file.pdf'<\/span>,\r\n  <span class=\"hljs-attr\">success<\/span>: <span class=\"hljs-keyword\">function<\/span> (<span class=\"hljs-params\">res<\/span>) {\r\n    <span class=\"hljs-keyword\">if<\/span> (res.<span class=\"hljs-property\">statusCode<\/span> === <span class=\"hljs-number\">200<\/span>) {\r\n      uni.<span class=\"hljs-title function_\">saveFile<\/span>({\r\n        <span class=\"hljs-attr\">tempFilePath<\/span>: res.<span class=\"hljs-property\">tempFilePath<\/span>,\r\n        <span class=\"hljs-attr\">success<\/span>: <span class=\"hljs-keyword\">function<\/span> (<span class=\"hljs-params\">saveRes<\/span>) {\r\n          <span class=\"hljs-variable language_\">console<\/span>.<span class=\"hljs-title function_\">log<\/span>(<span class=\"hljs-string\">'\u6587\u4ef6\u4e0b\u8f7d\u6210\u529f\uff0c\u4fdd\u5b58\u8def\u5f84\u4e3a\uff1a'<\/span> + saveRes.<span class=\"hljs-property\">savedFilePath<\/span>);\r\n        }\r\n      });\r\n    }\r\n  }\r\n});\r\n<\/code><\/pre>\n<p>In the code above, we downloaded a file using the uni.downloadFile() method, and after successful download, we saved the file to a specified directory using the uni.saveFile() method. The savedFilePath parameter in the saveFile() method can be used to specify the directory where the file is saved.<\/p>\n<p>It is important to note that uniapp is a cross-platform development framework based on webview, and there may be some restrictions or differences on different platforms. The specific download directory settings may vary. It is recommended to adapt and adjust according to the specific project&#8217;s needs and platform characteristics.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In uniapp, you can specify the file download directory using the uni.downloadFile() method. The specific steps are as follows: To start, make sure to import the uni.downloadFile() method in your Uniapp page. Call the uni.downloadFile() method at the place where you need to download the file, and specify the download directory for the file. The [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[13672,2892,269,13673,1873],"class_list":["post-10816","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-download-directory","tag-file-download","tag-mobile-development","tag-uni-downloadfile","tag-uniapp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Uniapp Download Directory Setup Guide - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"Learn how to set download directories in Uniapp with uni.downloadFile(). Step-by-step code tutorial for mobile apps.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Uniapp Download Directory Setup Guide\" \/>\n<meta property=\"og:description\" content=\"Learn how to set download directories in Uniapp with uni.downloadFile(). Step-by-step code tutorial for mobile apps.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-14T12:50:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-04T04:17:59+00:00\" \/>\n<meta name=\"author\" content=\"Liam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:site\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Liam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/\"},\"author\":{\"name\":\"Liam\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/23786905eb7b377f45ddb01c17da7671\"},\"headline\":\"Uniapp Download Directory Setup Guide\",\"datePublished\":\"2024-03-14T12:50:34+00:00\",\"dateModified\":\"2025-08-04T04:17:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/\"},\"wordCount\":167,\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"keywords\":[\"download directory\",\"File Download\",\"Mobile development\",\"uni.downloadFile\",\"Uniapp\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/\",\"name\":\"Uniapp Download Directory Setup Guide - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\"},\"datePublished\":\"2024-03-14T12:50:34+00:00\",\"dateModified\":\"2025-08-04T04:17:59+00:00\",\"description\":\"Learn how to set download directories in Uniapp with uni.downloadFile(). Step-by-step code tutorial for mobile apps.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.silicloud.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Uniapp Download Directory Setup Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"name\":\"Silicon Cloud Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\",\"name\":\"Silicon Cloud Blog\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"contentUrl\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"width\":1024,\"height\":1024,\"caption\":\"Silicon Cloud Blog\"},\"image\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\",\"https:\/\/twitter.com\/SiliCloudGlobal\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/23786905eb7b377f45ddb01c17da7671\",\"name\":\"Liam\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8d37ed3e7f770dde8bf069ba0b4298688028c3abaacf1131742fc1352d174ebd?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8d37ed3e7f770dde8bf069ba0b4298688028c3abaacf1131742fc1352d174ebd?s=96&d=mm&r=g\",\"caption\":\"Liam\"},\"sameAs\":[\"http:\/\/Wilson\"],\"url\":\"https:\/\/www.silicloud.com\/blog\/author\/liamwilson\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Uniapp Download Directory Setup Guide - Blog - Silicon Cloud","description":"Learn how to set download directories in Uniapp with uni.downloadFile(). Step-by-step code tutorial for mobile apps.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/","og_locale":"en_US","og_type":"article","og_title":"Uniapp Download Directory Setup Guide","og_description":"Learn how to set download directories in Uniapp with uni.downloadFile(). Step-by-step code tutorial for mobile apps.","og_url":"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/","og_site_name":"Blog - Silicon Cloud","article_publisher":"https:\/\/www.facebook.com\/SiliCloudGlobal\/","article_published_time":"2024-03-14T12:50:34+00:00","article_modified_time":"2025-08-04T04:17:59+00:00","author":"Liam","twitter_card":"summary_large_image","twitter_creator":"@SiliCloudGlobal","twitter_site":"@SiliCloudGlobal","twitter_misc":{"Written by":"Liam","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/#article","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/"},"author":{"name":"Liam","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/23786905eb7b377f45ddb01c17da7671"},"headline":"Uniapp Download Directory Setup Guide","datePublished":"2024-03-14T12:50:34+00:00","dateModified":"2025-08-04T04:17:59+00:00","mainEntityOfPage":{"@id":"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/"},"wordCount":167,"publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"keywords":["download directory","File Download","Mobile development","uni.downloadFile","Uniapp"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/","url":"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/","name":"Uniapp Download Directory Setup Guide - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/#website"},"datePublished":"2024-03-14T12:50:34+00:00","dateModified":"2025-08-04T04:17:59+00:00","description":"Learn how to set download directories in Uniapp with uni.downloadFile(). Step-by-step code tutorial for mobile apps.","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/blog\/how-can-i-set-the-download-directory-for-files-in-uniapp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.silicloud.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Uniapp Download Directory Setup Guide"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/blog\/#website","url":"https:\/\/www.silicloud.com\/blog\/","name":"Silicon Cloud Blog","description":"","publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.silicloud.com\/blog\/#organization","name":"Silicon Cloud Blog","url":"https:\/\/www.silicloud.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","contentUrl":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","width":1024,"height":1024,"caption":"Silicon Cloud Blog"},"image":{"@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/SiliCloudGlobal\/","https:\/\/twitter.com\/SiliCloudGlobal"]},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/23786905eb7b377f45ddb01c17da7671","name":"Liam","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8d37ed3e7f770dde8bf069ba0b4298688028c3abaacf1131742fc1352d174ebd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8d37ed3e7f770dde8bf069ba0b4298688028c3abaacf1131742fc1352d174ebd?s=96&d=mm&r=g","caption":"Liam"},"sameAs":["http:\/\/Wilson"],"url":"https:\/\/www.silicloud.com\/blog\/author\/liamwilson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/10816","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/comments?post=10816"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/10816\/revisions"}],"predecessor-version":[{"id":154586,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/10816\/revisions\/154586"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/media?parent=10816"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/categories?post=10816"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/tags?post=10816"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}