|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
kodaliece@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. jstucklex@attglobal.net ================== |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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? |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
kodaliece@gmail.com wrote:
> On Feb 18, 7:20 pm, kodali...@gmail.com wrote: >> On Feb 18, 6:34 pm, 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? works for me. check that file uploading is turned on..think there is a php.ini switch.. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On Feb 18, 8:36pm, The Natural Philosopher <a...@b.c> wrote:
> kodali...@gmail.com wrote: > > On Feb 18, 7:20 pm, kodali...@gmail.com wrote: > >> On Feb 18, 6:34 pm, 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? > > works for me. check that file uploading is turned on..think there is a > php.ini switch..- Hide quoted text - > > - Show quoted text - Hi, File Uploading is turned on in php.ini file. The same program worked for me when I run on IIS. But is not working when I run it with tomcat. |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
kodaliece@gmail.com wrote:
> On Feb 18, 8:36 pm, The Natural Philosopher <a...@b.c> wrote: >> kodali...@gmail.com wrote: >>> On Feb 18, 7:20 pm, kodali...@gmail.com wrote: >>>> On Feb 18, 6:34 pm, 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? >> works for me. check that file uploading is turned on..think there is a >> php.ini switch..- Hide quoted text - >> >> - Show quoted text - > > Hi, > File Uploading is turned on in php.ini file. The same program worked > for me when I run on IIS. But is not working when I run it with tomcat. > I would suggest, then, you follow up in a tomcat newsgroup. The fact it works on IIS says your PHP code is fine. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
![]() |
| Outils de la discussion | |
|
|