Skip to content

Silent sqlpage.persist_uploaded_file() option? #278

Answered by lovasoa
matthewlarkin asked this question in Q&A
Discussion options

You must be logged in to vote

Oh, I see, you are talking about the case when the user did submit the form that contained a file upload field, but left it blank. Not the case of the user loading the URL of the form target directly, or submitting another form that did not contain a file input.

By default, the browser will send an empty file, with a mime type of application/octet-stream.

You can use that to trigger the redirection:

select 'redirect' as component, '/upload_form.sql' as link
where sqlpage.uploaded_file_mime_type('file') NOT LIKE 'image/%';

I'll add this to the official "image gallery" example.

Replies: 2 comments 12 replies

Comment options

You must be logged in to vote
11 replies
@lovasoa
Comment options

@matthewlarkin
Comment options

@matthewlarkin
Comment options

@lovasoa
Comment options

Answer selected by matthewlarkin
@matthewlarkin
Comment options

@matthewlarkin
Comment options

@lovasoa
Comment options

@matthewlarkin
Comment options

Comment options

You must be logged in to vote
1 reply
@lovasoa
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
functions Related to built-in sqlpage functions
2 participants