Jump to content

Archived

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

HoTDaWg

Uploading Images Problem

Recommended Posts

hello,

I have this script which allows users to upload files. I get the following error:

[code]
Parse error: syntax error, unexpected ',' in /home/cortez/public_html/testscripts/photoalbums/upload.php on line 2
[/code]

All i want to do is to be able to have more than just .gif images available for upload. I want jpg, and bmp, etc.

here is the code for upload.html

[code]
<html>
<head>
<title>Upload now!</title>
</head>

<form action="upload.php" method="post" enctype="multipart/form-data">
  <p>File Upload</p>
  <label for="file">File</label>
  <input type="file" name="file" id="file" />
  <br />
  <input type="submit" name="submit" value="Submit" />

</form>
<body bgcolor="#FFFFFF">

</body>


</html>
[/code]

and the code for upload.php

[code]

<?php
if (($_FILES["file"]["type"] == "image/gif", "images/jpg") &&
($_FILES["file"]["size"] < 150000)) {
  echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
  echo "Uploading " . $_FILES["file"]["name"];
  echo " (" . $_FILES["file"]["type"] . ", ";
  echo ceil($_FILES["file"]["size"] / 1024) . " Kb).<br />";

  if (file_exists("uploads/" . $_FILES["file"]["name"])) {
    echo $_FILES["file"]["name"] . " already exists.  ";
    echo "Please delete the destination file and try again.";
  } else {
    move_uploaded_file($_FILES["file"]["tmp_name"],
    "uploads/" . $_FILES["file"]["name"]);
    echo "File has been stored in your uploads directory.";
  }

} else
  echo "Sorry, we only accept .GIF images under 15Kb for upload.";
?>
[/code]

help would be greatly appreciated. Thanks.

HoTDaWg

Share this post


Link to post
Share on other sites
Try

[code]

<?php
if (($_FILES["file"]["type"] == "image/gif" OR "images/jpg") &&
($_FILES["file"]["size"] < 150000)) {
  echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
  echo "Uploading " . $_FILES["file"]["name"];
  echo " (" . $_FILES["file"]["type"] . ", ";
  echo ceil($_FILES["file"]["size"] / 1024) . " Kb).<br />";

  if (file_exists("uploads/" . $_FILES["file"]["name"])) {
    echo $_FILES["file"]["name"] . " already exists.  ";
    echo "Please delete the destination file and try again.";
  } else {
    move_uploaded_file($_FILES["file"]["tmp_name"],
    "uploads/" . $_FILES["file"]["name"]);
    echo "File has been stored in your uploads directory.";
  }

} else
  echo "Sorry, we only accept .GIF images under 15Kb for upload.";
?> [/code]

Share this post


Link to post
Share on other sites

×

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.