Jump to content

[help]error uploading file

- - - - -

  • Please log in to reply
2 replies to this topic

#1
dapidmini

dapidmini

    Newbie

  • Members
  • Pip
  • 2 posts
I'm trying to upload a file using fileupload but the tmp_name for that file doesn't exist.. the tmp_name is C:\xampp\tmp\php154E.tmp what am I doing wrong? I followed the instructions from tizag and w3schools and here's my code so far:
<?php

if ($_FILES["myfile"]["error"] > 0)

{

	echo "Error: " . $_FILES["myfile"]["error"] . "<br />";

}

else

{

	echo "Upload: " . $_FILES["myfile"]["name"] . "<br />";

	echo "Type: " . $_FILES["myfile"]["type"] . "<br />";

	echo "Size: " . ($_FILES["myfile"]["size"] / 1024) . " Kb<br />";

	echo "Stored in: " . $_FILES["myfile"]["tmp_name"];

	$targetpath = 'tmpimage/'.$_FILES["myfile"]["name"];

	if(move_uploaded_file($_FILES['myfile']['name'], $target_path)) {

		echo "The file ".  basename( $_FILES['myfile']['name']). " has been uploaded";

	} else{

		echo "There was an error uploading the file, please try again!";

	}

}

?>



#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
1) does C:\xampp\tmp\ exist?
2) what are the permissions on that folder set to?

Sometimes the issue isn't with the code.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
fazlerocks

fazlerocks

    Newbie

  • Members
  • PipPip
  • 12 posts
Check that the directory "tmpimage" is in the same directory where the script is running. Hope it helps you.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users