Re: File upload problem
On Feb 18, 7:20pm, kodali...@gmail.com wrote:
> On Feb 18, 6:34pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>
>
>
>
>
> > kodali...@gmail.com wrote:
> > > Hi All,
>
> > > I am using a simple php script to learn file upload functionality in
> > > php.
>
> > > Below is my html form code:
> > > <html>
> > > <title>
> > > File Upload FORM
> > > </title>
> > > <body>
> > > <form action="upload_file.php" method="POST" enctype="multipart/form-
> > > data">
> > > Select your file: <input type="file" name="inputFile"
> > > id="inputFile">
> > > <BR>
> > > <input type="submit" value="Upload">
> > > </form>
> > > </body>
> > > </html>
>
> > > and my upload_file.php file is:
> > > <?php
> > > // chekc the type of the content uploaded
> > > if (($_FILES["inputFile"]["type"] == "image/gif") ||
> > > ($_FILES["inputFile"]["type"] == "image/jpg") ||
> > > ($_FILES["inputFile"]["type"] == "image/pjpeg") &&
> > > ($_FILES["inputFile"]["size"] > 20000))
> > > {
> > > if ($_FILES["inputFile"]["error"] > 0)
> > > echo "Error: ".$_FILES["inputFile"]["error"]."<br/>";
> > > else
> > > {
> > > if (file_exists("upload/".$_FILES["inputFile"]["name"]))
> > > echo "Error: File \""."upload/"..$_FILES["inputFile"]["name"]."\"
> > > already exists!";
> > > else
> > > {
> > > move_uploaded_file($_FILES["inputFile"]["tmp_name"], "upload/".
> > > $_FILES["inputFile"]["name"]);
> > > echo "Stored the file: ".$_FILES["inputFile"]["name"];
> > > }
> > > }
> > > }
> > > else
> > > {
> > > echo "Invalid File";
> > > }
> > > ?>
>
> > > But this is not uploading the file and is always printing "Invalid
> > > File". So I tried to echo the file name, type, size and error values.
> > > But its printing nothing. The same code worked with IIS. But, now I am
> > > using tomcat and its not working.
>
> > > Can any one please me on this.
>
> > > Thanks in advance,
> > > Mohan
>
> > What do you have in your $_FILES array? i.e.
>
> > echo "<pre>\n";
> > print_r($_FILES);
> > echo "</pre>\n";
>
> > --
> > ==================
> > Remove the "x" from my email address
> > Jerry Stuckle
> > JDS Computer Training Corp.
> > jstuck...@attglobal.net
> > ==================- Hide quoted text-
>
> > - Show quoted text -
>
> I used ur piece of code:
> echo "<pre>\n";
> print_r($_FILES);
> echo "</pre>\n";
>
> It displayed the following:
> Array
> (
> )
>
> Noting is in $_FILES array variable. But, I could not why this is
> happening.
>
> Mohan- Hide quoted text -
>
> - Show quoted text -
I am using PHP 5.2.5, apache-tomcat-5.5.26. Somewhere on the net I
read that tomcat doesn't allow enctype="multipart/form-data". Is this
true? If so, what should be done?
|