# Using Front-End File Uploads in SmartForms

<figure><img src="https://728196400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0Lugni2T5TewiPeYs1ka%2Fuploads%2FQRu2hv5Pnl5zkRks1WGV%2Fimage.png?alt=media&#x26;token=0a8a3215-1510-42b9-8c1e-6d109166bb68" alt=""><figcaption></figcaption></figure>

FormWise allows you to **enable file uploads in SmartForms**, so your **end users** can upload **PDFs, CSVs, and TXT files** to be processed by AI in real-time. This is useful for:

✅ **Summarizing long documents** (contracts, reports, research papers).\
✅ **Extracting key data from structured files** (CSV spreadsheets, customer records).\
✅ **Generating AI-powered insights** based on user-provided information.

However, **large files, too many uploads, or combining file uploads with web browsing & web scraping** can **cause timeouts**. This guide covers **best practices** for setting up SmartForms with file uploads and how AI processes this data.

***

### **1️⃣ How Front-End File Uploads Work in SmartForms**

When a **SmartForm includes a file upload field**, your end users can:\
🔹 **Upload PDFs, CSVs, or TXT files** directly into the form.\
🔹 Have AI **process the file’s content** and generate a response based on the text.\
🔹 Receive **a personalized AI-generated output** based on their uploaded document.

💡 **Example Use Cases:**

* **A legal firm:** Uploads a **PDF contract** and AI extracts key clauses.
* **A financial advisor:** Uploads a **CSV with expense data** and AI generates a budget plan.
* **A real estate agent:** Uploads a **property listing** and AI writes a marketing description.

{% hint style="info" %}
Ensure you actually add the front-end uploaded data source to your prompt instruction. See screenshot below.
{% endhint %}

<figure><img src="https://728196400-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0Lugni2T5TewiPeYs1ka%2Fuploads%2Fbh9wfCh6KAAPlvcw6qbK%2Fimage.png?alt=media&#x26;token=d8a3c293-bb38-4b14-8dfd-1735c34d24c3" alt=""><figcaption></figcaption></figure>

***

### **2️⃣ Best Practices for Front-End File Uploads**

#### **🔹 File Size Limits by Plan**

📌 **Pro Plan** – **2MB max per file** (multiple files allowed).\
📌 **Agency Plan** – **20MB max per file** (multiple files allowed).

🚀 **You can attach multiple files**, but larger files or too many files **can lead to token issues and timeouts.**

#### **🔹 Number of Files Limit**

✅ There is **no hard limit** on the number of uploaded files.\
🚨 However, **too many files at once can cause AI to hit token limits**, making responses incomplete or failing to generate.

***

### **3️⃣ How AI Processes Uploaded Files (RAG in Simple Terms)**

#### **🔹 What Happens When a User Uploads a File?**

1️⃣ The AI **reads the file’s text** and extracts **key details**.\
2️⃣ The AI **retrieves** the most relevant information when responding.\
3️⃣ AI does **not** "train" on the file—it **only references the text during that session.**

💡 This is called **Retrieval-Augmented Generation (RAG)**—think of it like **a smart document search,** where AI pulls out the most relevant data when needed.

🚨 **If an uploaded file is too large or contains too much information, AI may struggle to find the most relevant text, leading to slow or incomplete responses.**

***

### **4️⃣ How Files Are Stored for End Users**

✅ **Files are temporarily stored in the user's browser cookies**.\
✅ If they **refresh the page**, their uploaded files will still be there **for that session** (so they don’t need to re-upload).\
✅ Once they **leave the session**, the files are no longer stored.

📌 **This improves the user experience**, allowing them to navigate within the tool without losing their uploaded data.

***

### **5️⃣ Avoiding Timeouts & Optimizing Performance**

🔹 **If your SmartForm is timing out:**\
✅ **Reduce file sizes** (split large PDFs into sections).\
✅ **Limit the number of uploaded files** per request.\
✅ **Avoid combining uploads with web browsing or web scraping** in the same request.\
✅ **Ensure smartform prompts are structured to retrieve only necessary information** from the file.

📌 **Example Fix:**\
❌ **Bad:** "Analyze the entire 50-page PDF and provide a full summary."\
✅ **Better:** "Find and summarize the key financial terms from the contract PDF."

🚀 **By following these best practices, you ensure AI tools process user uploads efficiently without timeouts.**
