Jump to content

[SOLVED] Unable to upload files


tomjung09

Recommended Posts

I'm trying to do a simple upload from client computer to a directory on my server.

 

I have checked the folder settings and it is chmod 777.

 

This is my code:

	$path = $date . $x .".". "jpg";
$image2[$x] = $path;

if ($_FILES["txtimage1"]["error"] > 0)
  {
  echo "Error: " . $_FILES["txtimage1"]["error"] . "<br />";
  }
else
  {
  echo "Upload: " . $_FILES["txtimage1"]["name"] . "<br />";
  echo "Type: " . $_FILES["txtimage1"]["type"] . "<br />";
  echo "Size: " . ($_FILES["txtimage1"]["size"] / 1024) . " Kb<br />";
  echo "Stored in: " . $_FILES["txtimage1"]["tmp_name"];
  }


if(copy($_FILES['uploadedfile']['tmp_name'], $path)){echo "uploaded \n";}

 

It outputs:

Upload: 13332118_1X.JPG

Type: image/jpeg

Size: 88.9501953125 Kb

Stored in: c:\winnt\temp\php4\php1190.tmp success 

 

I have tried setting the path to <filename> .jpg and .jpeg

neither works, I am to the point where I am just trying to get it to upload to the directory that the php file resides in.

 

The file txtimage1 is being called from contains the form and file form:

<form id="form1" name="form1" method="post" action="uploadbikesubmit.php" enctype="multipart/form-data">
<input type="file" name="txtimage1"/>

 

Any ideas on what might be causing the problem or things I might try?

 

I have also tried the move_uploaded_file() function, no luck there either.

 

 

Link to comment
Share on other sites

So...I had the wrong name for the copy($_FILES['uploadedfile']['tmp_name'], $path)

 

it should have been copy($_FILES['txtimage1']['tmp_name'], $path)

 

I'm a little perplexed as to why copy() works but move_uploaded_file() does not.

 

At any rate, I suppose I spent 5 hours looking for something right in front of me.... I've been at this too long.

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.