Re: file upload
| From: | Alexander Weber | Date: | Sat, 05 Apr 2003 08:15:09 +0000 |
| Subject: | Re: file upload | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142515@lists.php.net to get a copy of this message | ||
Seems correct to me, try to upload the file with different browsers. Opera,
Netscape, M$. e.g. Rich Text could be: application/MSword, text/richtext,
and some other "nice" applications.... ;-)
Cheers,
Alex
"Anders Thoresson" <listor@thoresson.net> schrieb im Newsbeitrag
news:oprmz4e2jbzzwwoi@mail.darkface.pp.se...
> Am I making any obvious mistakes here, in my upload script? I want to
> upload text-files only, they should end up in the directory from which the
> script is executed and be names __traningsmatcher.txt.
>
> HTML-form:
>
> <FORM ENCTYPE="multipart/form-data" METHOD=POST ACTION="store.php">
> <TABLE>
> <INPUT NAME="max_file_size" TYPE="hidden" VALUE="3000000">
> <TR>
> <TD>Fil: </TD>
> <TD><INPUT NAME="userfile" TYPE="file"></TD>
> </TR>
> <TR>
> <TD></TD>
> <TD><INPUT TYPE=submit VALUE=" skicka "></TD>
> </TR>
> </TABLE>
> </FORM>
>
>
> And php, on the recieving end:
> <?php
>
> // check and validate uploaded file
>
> if($_FILES['userfile'] == "none") {
> die("Problem: Ingen fil uppladdad.");
> }
>
>
> if($_FILES['userfile']['size'] == 0) {
> die("Problem: Filen är tom.");
> }
>
> if($_FILES['userfile']['type'] != "text/plain") {
> die("Problem: Filen är inte en textfil.");
> }
>
>
> if(!is_uploaded_file($_FILES['userfile']['tmp_name'])) {
> die("Problem: Filen är inte uppladdad");
> }
>
> $upfile = "__traningsmatcher.txt";
>
> if(!copy($_FILES['userfile']['tmp_name'], $upfile)) {
> die("Kunde inte spara filen");
> }
>
> echo("Filen är sparad!");
>
>
> ?>
>
> --
> anders thoresson