Jump to content

Archived

This topic is now archived and is closed to further replies.

believeinsharing

$_FILES brower problem

Recommended Posts

Hi,

I have simple php code with HTML.. but its not working with all browser, some time its works in Chrome sometimes its not working in IE

I have saved this filr as index.php

 

its code is:

 

<html>

<head> <title>

Upload

</title> </head>

<body>

<form action="index2.php" method="POST" enctype="multipart/form-data">

Image:

<input type="file" name="myImage" />

<input type="submit" value="Upload" />

</form>

<?php

 

echo $_FILES["myImage"]["tmp_name"];

 

?>

</body>

</html>

Share this post


Link to post
Share on other sites

Try this?

 

<html>
<head> <title>
Upload
</title> </head>
<body>
<form action="index.php" method="POST" enctype="multipart/form-data">
Image:
<input type="file" name="myImage" />
<input type="submit" value="Upload" />
</form>
<?PHP

  if($_SERVER['REQUEST_METHOD'] == 'POST') {
    echo $_FILES["myImage"]["tmp_name"];
  } else {
    echo 'No form has been submitted.';
  }

?>
</body>
</html>

Share this post


Link to post
Share on other sites

@ PaulRyan:

 

Hi thanks for ur reply..

 

I copied ur code, its working in chrome, but in IE its showing default echo statement for a first time ie "No form has been submitted. " but once u select an image in click on upload from get clear.. no data in "file type" and nothing in echo...

 

does it prob with brower or code?

 

Thanks again

Share this post


Link to post
Share on other sites

See if there is an error in the $_FILES array.

 

if($_SERVER['REQUEST_METHOD'] == 'POST') {
    echo "Errors: {$_FILES['myImage']['error']}<br>"; // <--- ADD THIS LINE
    echo $_FILES["myImage"]["tmp_name"];
  } else {
    echo 'No form has been submitted.';
  }

Share this post


Link to post
Share on other sites

@ Pikachu2000:

 

Thanks alot  ur code is working in both chrome and IE..

 

I am new to PHP that why not sure what ws the prob.. if u tell me more abt the code this will help me in future..

 

thanks again

 

 

 

 

Share this post


Link to post
Share on other sites

There is no reason for the line I added to make it all of a sudden start working. Something else must have changed.

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.