Jump to content

[SOLVED] Upload image


emediastudios

Recommended Posts

Hi everyone, i am having this problem wher my script keeps telling me i have attempted to upload a invalid file.

and it isnt.

Here is my code

<?php require_once('../../Connections/worldgym.php');
error_reporting(E_ALL);

//This gets all the other information from the form 
$photo=($_FILES['photo']['name']); 
$title=$_POST['title']; 

if ((($_FILES["photo"]["type"] == "image/gif")
|| ($_FILES["photo"]["type"] == "image/jpeg")
|| ($_FILES["photo"]["type"] == "image/jpg")
|| ($_FILES["photo"]["type"] == "image/pjpeg"))
&& ($_FILES["photo"]["size"] < 20000000))
  {
  if ($_FILES["photo"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["photo"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["photo"]["name"] . "<br />";
    echo "Type: " . $_FILES["photo"]["type"] . "<br />";
    echo "Size: " . ($_FILES["photo"]["size"] / 10240) . " Kb<br />";
    echo "Temp file: " . $_FILES["photo"]["tmp_name"] . "<br />";    if (file_exists("../gallery/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["photo"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["photo"]["tmp_name"],
      "../gallery/" . $_FILES["photo"]["name"]);
      echo "Stored in: " . "../gallery/" . $_FILES["photo"]["name"];
      }
    }
  }
else
  {
  echo "Invalid file";
  }
?>

 

My form is like this

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upload</title>
<style type="text/css">
<!--
.style1 {
color: #FFFFFF;
font-weight: bold;
}
-->
</style>
</head>

<body>
<form id="form1" name="form1" method="post" action="process.php">
  <table width="800" border="0" align="center">
    <tr>
      <td colspan="2" bgcolor="#666666"><div align="center" class="style1">Image Upload Form</div></td>
    </tr>
    <tr>
      <td>Select Image</td>
      <td><label>
        <input type="file" name="photo" id="photo" />
      </label></td>
    </tr>
    <tr>
      <td>Image Description</td>
      <td><label>
        <textarea name="title" cols="45" rows="10" id="title"></textarea>
      </label></td>
    </tr>
    <tr>
      <td> </td>
      <td><label>
        <input type="submit" name="button" id="button" value="Upload" />
      </label></td>
    </tr>
    <tr>
      <td colspan="2" bgcolor="#666666"> </td>
    </tr>
  </table>
</form>
</body>
</html>

 

What could be possibly wrong.

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.