mirror of
https://github.com/zebrajr/localGPT.git
synced 2025-12-06 00:20:19 +01:00
feat: Update frontend file validation to accept MD, DOC, TXT, and HTML formats
- Update IndexForm.tsx to accept .md, .doc, .txt, .html, .htm file extensions - Update IndexWizard.tsx file input accept attribute for new formats - Update chat-input.tsx validation logic to handle new MIME types and extensions - Update empty-chat-state.tsx validation logic for comprehensive file support - Update test-upload.html to accept all supported file formats - Resolves frontend file upload restrictions for unstructured document formats Co-Authored-By: PromptEngineer <jnfarooq@outlook.com>
This commit is contained in:
parent
583c72e340
commit
8f3417af15
|
|
@ -99,7 +99,7 @@ export function IndexForm({ onClose, onIndexed }: Props) {
|
|||
>
|
||||
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" className="mb-2 text-white/80"><path d="M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"/><polyline points="7 10 12 5 17 10"/><line x1="12" y1="5" x2="12" y2="16"/></svg>
|
||||
<span className="text-xs text-gray-400">Drag & Drop documents here or click to browse</span>
|
||||
<input id="file-upload" type="file" accept="application/pdf,.docx,.html,.htm" multiple className="hidden" onChange={(e)=>setFiles(e.target.files)} />
|
||||
<input id="file-upload" type="file" accept="application/pdf,.docx,.doc,.html,.htm,.md,.txt" multiple className="hidden" onChange={(e)=>setFiles(e.target.files)} />
|
||||
</label>
|
||||
{files && <p className="mt-1 text-xs text-green-400">{files.length} file(s) selected</p>}
|
||||
</div>
|
||||
|
|
@ -220,4 +220,4 @@ export function IndexForm({ onClose, onIndexed }: Props) {
|
|||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ export function IndexWizard({ onClose }: Props) {
|
|||
<div className="space-y-4">
|
||||
<div>
|
||||
<label className="block text-sm mb-1">Document files</label>
|
||||
<input type="file" accept="application/pdf,.docx,.html,.htm" multiple onChange={handleFile} className="text-sm" />
|
||||
<input type="file" accept="application/pdf,.docx,.doc,.html,.htm,.md,.txt" multiple onChange={handleFile} className="text-sm" />
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
|
|
@ -69,4 +69,4 @@ export function IndexWizard({ onClose }: Props) {
|
|||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -91,10 +91,17 @@ export function ChatInput({
|
|||
|
||||
if (file.type === 'application/pdf' ||
|
||||
file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
|
||||
file.type === 'application/msword' ||
|
||||
file.type === 'text/html' ||
|
||||
file.type === 'text/markdown' ||
|
||||
file.type === 'text/plain' ||
|
||||
file.name.toLowerCase().endsWith('.pdf') ||
|
||||
file.name.toLowerCase().endsWith('.docx') ||
|
||||
file.name.toLowerCase().endsWith('.doc') ||
|
||||
file.name.toLowerCase().endsWith('.html') ||
|
||||
file.name.toLowerCase().endsWith('.htm') ||
|
||||
file.name.toLowerCase().endsWith('.docx')) {
|
||||
file.name.toLowerCase().endsWith('.md') ||
|
||||
file.name.toLowerCase().endsWith('.txt')) {
|
||||
newFiles.push({
|
||||
id: crypto.randomUUID(),
|
||||
name: file.name,
|
||||
|
|
@ -157,7 +164,7 @@ export function ChatInput({
|
|||
|
||||
<div className="bg-white/5 backdrop-blur border border-white/10 rounded-2xl px-5 pt-4 pb-3 space-y-2">
|
||||
{/* Hidden file input (kept for future use) */}
|
||||
<input ref={fileInputRef} type="file" accept=".pdf,.docx,.html,.htm" multiple onChange={handleFileChange} className="hidden" />
|
||||
<input ref={fileInputRef} type="file" accept=".pdf,.docx,.doc,.html,.htm,.md,.txt" multiple onChange={handleFileChange} className="hidden" />
|
||||
|
||||
{/* Textarea */}
|
||||
<textarea
|
||||
|
|
@ -204,4 +211,4 @@ export function ChatInput({
|
|||
</form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -117,10 +117,17 @@ export function EmptyChatState({
|
|||
const file = files[i];
|
||||
if (file.type === 'application/pdf' ||
|
||||
file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
|
||||
file.type === 'application/msword' ||
|
||||
file.type === 'text/html' ||
|
||||
file.type === 'text/markdown' ||
|
||||
file.type === 'text/plain' ||
|
||||
file.name.toLowerCase().endsWith('.pdf') ||
|
||||
file.name.toLowerCase().endsWith('.docx') ||
|
||||
file.name.toLowerCase().endsWith('.doc') ||
|
||||
file.name.toLowerCase().endsWith('.html') ||
|
||||
file.name.toLowerCase().endsWith('.htm') ||
|
||||
file.name.toLowerCase().endsWith('.docx')) {
|
||||
file.name.toLowerCase().endsWith('.md') ||
|
||||
file.name.toLowerCase().endsWith('.txt')) {
|
||||
newFiles.push({
|
||||
id: crypto.randomUUID(),
|
||||
name: file.name,
|
||||
|
|
@ -224,7 +231,7 @@ export function EmptyChatState({
|
|||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept=".pdf,.docx,.html,.htm"
|
||||
accept=".pdf,.docx,.doc,.html,.htm,.md,.txt"
|
||||
multiple
|
||||
onChange={handleFileChange}
|
||||
className="hidden"
|
||||
|
|
@ -282,4 +289,4 @@ export function EmptyChatState({
|
|||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
<body>
|
||||
<h1>Test PDF Upload</h1>
|
||||
<form id="uploadForm">
|
||||
<input type="file" id="fileInput" accept=".pdf,.docx,.html,.htm" />
|
||||
<input type="file" id="fileInput" accept=".pdf,.docx,.doc,.html,.htm,.md,.txt" />
|
||||
<button type="submit">Upload PDF</button>
|
||||
</form>
|
||||
|
||||
|
|
@ -51,4 +51,4 @@
|
|||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Loading…
Reference in New Issue
Block a user