Upload required! =)

ulsen 11 Feb, 2008
Hi everyone,

I have one input field...

<input id="foto1" name="Foto1" type="file" />


...that has to be filled out. so i need my form to validate this. under "validation" -> "1 - required (not blank)" i put the name of the field "Foto1", but it won't validate it. Any ideas? Does it work with type="file"-fields anyway?

Thank you!!

Uli
GreyHead 12 Feb, 2008
Hi Uli,

I think that the Validation code (Andrew Tetlaw's Really Easy Form Validation from here) will handle this validation. I suspect that ChronoForms doesn't add the necessary code in form fields.

You can probably do this manually, it just needs the appropriate class name added: class="required"

Bob<br><br>Post edited by: GreyHead, at: 2008/02/13 12:09
ulsen 13 Feb, 2008
hmmm, having to use an external script would be a little disappointing. what i made the form for (and what i got chronoforms for in the first place) was to make sure the user uploads a file... well.

thank you anyway, i'll try out the script you posted!
GreyHead 13 Feb, 2008
Hi Uli,

The script is already installed - this is built into ChronoForms.

Just try adding the class attribute to your input field - like this:
<input class="required" id="foto1" name="Foto1" type="file" />
Bob
ulsen 13 Feb, 2008
Hi Bob,

sorry, got you wrong there before.

Anyway, I put class="required" into my input field now... it won't work. It still sends the email. Thing is, I have input fields for text and textarea fields and they get validated fine. It's just the one for uploading the file that causes trouble.

You can check out the form here

See, it tells you when things aren't filled out but you can send a mail without adding a file.

Thanks very much for helping me with this... Actually, I'm still using V2.3.7 ... maybe I should update.
GreyHead 13 Feb, 2008
Hi Ulsen,

Thanks for trying that, sorry it doesn't work. Looks as if something deeper in the code is needed. When I have some time I'll take a look.

ChronoForms 2.3.8 has a few bug-fixes but nothing that's going to affect this issue. The main change is the addition of the plug-ins feature to link to other databases.

Bob

PS Tried the form link but it needs registration and I can't find the registration form.<br><br>Post edited by: GreyHead, at: 2008/02/13 18:29
ulsen 14 Feb, 2008
Sorry, my bad.

This link will work.

Thanks a lot you're trying to help me out... it'd be quite handy if ChronoForms could do the trick.

So long,

Uli
GreyHead 14 Feb, 2008
Hi Uli,

Sorry, still can't see it, that link goes to the home page and the previous one gives me "Sie sind nicht berechtigt, diesen Bereich zu sehen. Sie müssen sich anmelden."

Bob
ulsen 15 Feb, 2008
aaaargh, hadn't published the menu item. :whistle: now go!
ulsen 05 Mar, 2008
Hi,

I was wondering if there is any solution to this problem yet... anybody with an idea how to validate that a file gets uploaded?

Right now my client has to either ignore emails without attachments or give an answer saying, "we're sorry, can you send your data again but this time with files attached?" :dry:

Thanks in advance for whatever anyone might reply to this...😉

Uli
GreyHead 05 Mar, 2008
Hi Uli,

I think you'd have to hack the code in chronocontact.php a little to add a check after the uploaded files are handled. You could use the same code as imagevalidation does to re-show the form.

Bob
Attila16881 20 Jan, 2009
i have the same problem. With ChronoForms i'm not able to set required upload.
Please, could you help me to hack chronocontact.php?
What code i have to add and where... thanks!
GreyHead 20 Jan, 2009
Hi Attila16881,

In ChronoForms v3.0 you could use server side validation to check that there is an entry in the $attachments array.

Bob
Attila16881 20 Jan, 2009
How could i use server side validation? Do i need just to set "yes" on "server side validation" and then insert the php code or i need something else on my webserver?

And this code to check if a file is uploaded is correct (file_2 is the name of the uploaded file)?

<?php
if (!is_uploaded_file($_FILES['file_2']) AND
!isset($error)) {
    $error = "<b>You have to upload a file!</b><br /><br />";
	unlink($_FILES['file_2']);
}

?>


thanks!
GreyHead 20 Jan, 2009
Hi Attilla16881,

I don't know for sure but something like that looks good to me.

Yes you just turn on and add the code. There's an example on the tab. I think you may need to return something???

Bob
Attila16881 30 Jan, 2009
i have tried to use different functions to check if the file is uploaded:

ISEMPTY
ISSET

all without any result... Someone could help me to setup a good file validation?
Attila16881 30 Jan, 2009
how can i use it if the filename is different every time?
I cannot change the filename of the uploaded file from users...
GreyHead 30 Jan, 2009
Hi Attilla16881,

Let's start over - please tell me what your question is as I've lost track.

ChronoForms checks the uploaded files, adds a bit to the file name to avoid over-writing existing files and puts them in the UpLoads folder. What is it that you need to do that is different?

Bob
Attila16881 10 Feb, 2009
i need that users must upload an image file (it needs to be a required field). I cannot handle with "required" option in html (it doesnt work) and i dont know how to do it in php (i have tried everything i said on these posts)
Max_admin 10 Feb, 2009
Hi Attila16881,

you will nee server side validation for this, something like :


<?php
if(!is_uploaded_file($_FILES['file_2'])) return "you must upload some file";
?>


this doesn't work ? do you get the file uploads fine when you try to choose one ?

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Attila16881 11 Feb, 2009
this solution doesnt work. When i dont upload file it gives me an error, when i upload a file it gives me the same error -.-
Max_admin 11 Feb, 2009
OK, try this instead:

    <?php
    if(!is_file($_FILES['file_2']['tmp_name'])) return "you must upload some file";
    ?>
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.