Jump to content

$_FILES Does Not Work on Windows


kev_120

Recommended Posts

Hey there, I'm having a PHP problem. Whenever I use the $_FILES superglobal to upload files via a form, it never seems to work when I run it on any Windows system. However, when I run it on my Mac, the image uploads just fine with the same script. What could the problem be? Thanks!

Link to comment
Share on other sites

<?

include 'http://www.faithum.org/header.php';

 

if (isset($_POST['submit']))

{

echo '<span style="float:left;">';

 

$path = getcwd();

define("IMAGEREPOSITORY",$path, true);

 

  if (is_uploaded_file($_FILES['image']['tmp_name']))

  {

  $imageresult = move_uploaded_file($_FILES['image']['tmp_name'],

  IMAGEREPOSITORY.$_FILES['image']['name']);

  }

  if ($imageresult)

  {

  echo "Image posted successfully!<br>";

  }

  else

  {

  echo "<font color=red>Image posting error!</font><br>";

  }

 

  include 'news.connect.php';

 

  $name = $_POST['name'];

  $article = $_POST['article'];

  $image = IMAGEREPOSITORY.$_FILES['image']['name'];

 

  $query = "INSERT INTO articles SET ID=LAST_INSERT_ID(), header='$name', article='$article',

  summary='$article', image='$image', timestamp=CURRENT_TIMESTAMP";

 

  $result = mysql_query($query);

 

  if ($result)

  {

      echo "Article posted successfully!";

 

  }

  else

  {

    echo "<font color=red>Article posting error!</font>";

  }

 

  echo '</span>';

 

  mysql_close();

}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.