Jump to content

I dont understand this error


ted_chou12

Recommended Posts

code here:
[code]
<?php if(isset($_POST['submit'])){

//checks file extension
$filename = $_FILES['uploadedfile']['name'];
$ext = explode(".", $filename);

if ($ext[1] != "jpg" && $ext[1] != "gif" && $ext[1] != "png" && $ext[1] !="jpeg")
{echo "<p><b>The file you uploaded does not have an image extension!</b></p>";}

else {
// Where the file is going to be placed
$target_path = "images/photo/";
$datetime = date("Y-m-d H:i:s");

$counter = ("images/photo/photonumber.txt");
$hits = file($counter);
$hits[0] ++;
$fp = fopen($counter , "w");
fputs($fp , "$hits[0]");
fclose($fp);
$number = file_get_contents("images/photo/photonumber.txt");

/* Add the original filename to our target path. 
Result is "uploads/filename.extension" */
$target_path = $target_path . basename($_FILES['uploadedfile']['name']);
$_FILES['uploadedfile']['tmp_name'];

$target_path = "images/photo/";

$target_path = $target_path . basename("photo".$number.".jpg");

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
{require("../mysqlconnection.php");
$insert = mysql_query("INSERT INTO photo(username, photonumber, photoname, photodate)
VALUES('$username', '$number', '$_FILES]['uploadedfile'['name']', '$datetime') ");//78
else
{echo"<p><b>There was an error uploading the image, please try again!</b></p>";}

if($insert === false)
{echo"<p><b>There was an error uploading the image, please try again!</b></p>";}
else
{header("location: confirm.php?confirm=photoedit_upload");}}}}?>
<form enctype="multipart/form-data" action="" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" name=submit value="Upload File" />
</form>
[/code]
Link to comment
Share on other sites

first of all:

those && should be || because it cannot have all of those extenstions at once

[code]if ($ext[1] != "jpg" && $ext[1] != "gif" && $ext[1] != "png" && $ext[1] !="jpeg") [/code]

next, get rid of the " around your var in this line:

[code]fputs($fp , "$hits[0]");[/code]

now see what errors u get
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.