roll_or_die Posted February 28, 2007 Share Posted February 28, 2007 i cant figure it out! i swear it used to work!ive gone over the code and cant see any problems, ive also made sure that the correct upload folder is on my localhost and it is!heres the code i have:members_pic_upload.html <form id="form1" name="form1" method="post" action="members_pic_upload.php"> <h1>Picture upload</h1> <p> <input type="file" name="file" /> <br /> <label> <input type="submit" name="Submit" value="Upload" /> </label> </p> </form> members_pic_upload.php: <?phpinclude "conn.php";$target_path = "memberpics/";$target_path = $target_path . basename( $_FILES['file']['name']); if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) { $filename=basename( $_FILES['file']['name']); //insert into database $username=$_SESSION['username']; $result=mysql_query ("SELECT * FROM members WHERE username = '$username'"); while($row=mysql_fetch_array($result)) { $userid=$row['id']; } //put in member pics db mysql_query("INSERT INTO member_pics(filename, userid) VALUES('$filename', '$userid')"); echo "<h1>Picture uploaded</h1><p>It will now appear on your profile!"; } else{ echo "There was an error uploading the file, please try again!";}?> i just keep receiving the error message, and the files arent transferring into the folder. can anyone see any problems? Link to comment Share on other sites More sharing options...
jesh Posted February 28, 2007 Share Posted February 28, 2007 When it was working before, was it on the same computer? Was it the same directory? If you recently changed the directory that the files are uploaded to, you might verify that the permissions on that directory are set such that PHP can write files to it. Link to comment Share on other sites More sharing options...
Anders Moen Posted February 28, 2007 Share Posted February 28, 2007 Well, to upload forms via a form, you need more in the form tag.You need: enctype="multipart/form-data"So your form code will be like this: <form id="form1" name="form1" method="post" action="members_pic_upload.php" enctype="multipart/form-data"> <h1>Picture upload</h1> <p> <input type="file" name="file" /> <br /> <label> <input type="submit" name="Submit" value="Upload" /> </label> </p></form> Link to comment Share on other sites More sharing options...
roll_or_die Posted February 28, 2007 Author Share Posted February 28, 2007 ahhh thanks it works now! hmmm that was wierd, i used to have that bit of code in it, i must have deleted the wrong file by accident or sumthin... Link to comment Share on other sites More sharing options...
Anders Moen Posted February 28, 2007 Share Posted February 28, 2007 Hehe, good it works again then Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now