tomjung09 Posted April 30, 2009 Share Posted April 30, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/156210-solved-unable-to-upload-files/ Share on other sites More sharing options...
tomjung09 Posted April 30, 2009 Author Share Posted April 30, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/156210-solved-unable-to-upload-files/#findComment-822410 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.