Jump to content

Uploading Images Problem


HoTDaWg

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
Link to comment
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]
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.