jvo Posted April 25, 2006 Share Posted April 25, 2006 Okay, so I've been trying to figure this out for a while. I've rewritten the code and checked for simple syntax error and I still get the same result. There's no error, but it just doesn't do anything. I've put an echo statement in there to test that the parameter has been set, but it obviously hasn't. Can anyone tell me why that is?Here's my code. It's a little primative, but I've not done any fine tuning. I just want to get it to do one thing first. Eventually, I want to have the URLs of the files to be saved to a DB, but as I've not yet gotten this to work, I haven't written it.[code]<html><head><title> .::Upload::. </title></head><body><?phpif(isset($_POST['upload1'])){ echo "Word Up"; //Upload path (relative to this file) $uploadDir = "images/"; $path1 = $uploadDir . basename($_FILES['upload1']['name']); echo "Word Up"; if(move_uploaded_file($_FILES['upload1']['tmp_name'],$path1)){ echo "The file ". basename($_FILES['upload1']['name'])." has been sucessfully uploaded"; } else{ echo "There was an error with your upload. Please try again."; } if(isset($_POST['upload2'])){ $path2 = $uploadDir . basename($_FILES['upload2']['name']); if(move_uploaded_file($_FILES['upload2']['tmp_name'],$path2)){ echo "The file ". basename($_FILES['upload2']['name'])." has been successfully uploaded"; } else{ echo "There was an error with your upload. Please try again."; } } if(isset($_POST['upload3'])){ $path3 = $uploadDir . basename($_FILES['upload3']['name']); if(move_uploaded_file($_FILES['upload3']['tmp_name'], $path3)){ echo "The file ". basename($_FILES['upload3']['name'])." has been successfully uploaded"; } else{ echo "There was an error with your upload. Please try again."; } } }?><form method="post" enctype="multipart/form-data"><input type="hidden" name="MAX_FILE_SIZE" value="650000"><font face="arial" pt size="2">File location: <input type="file" name="upload1"><br>File location: <input type="file" name="upload2"><br>File location: <input type="file" name="upload3"><br><input type="submit" value="Upload"></form></body></html>[/code]I'm trying to check that the value of atleast the first file has been set with [i]if (isset($_POST['upload1'])) {...[/i] but I'm guessing it's returning false and I don't know why. Can anyone shead some light on this? Quote Link to comment https://forums.phpfreaks.com/topic/8338-problem-with-uploading/ Share on other sites More sharing options...
jvo Posted April 25, 2006 Author Share Posted April 25, 2006 //bump Quote Link to comment https://forums.phpfreaks.com/topic/8338-problem-with-uploading/#findComment-30613 Share on other sites More sharing options...
Darkness Soul Posted April 25, 2006 Share Posted April 25, 2006 Try it.. =)D.Soul[code]<?phpif ( isset( $_POST['MAX_FILE_SIZE'] )){ $uploadDir = 'images/'; // Upload 1 if ( $HTTP_POST_FILES['upload1']['error'] == 0 ) { $path1 = $uploadDir . basename( $HTTP_POST_FILES['upload1']['name'] ); if ( move_uploaded_file ( $HTTP_POST_FILES['upload1']['tmp_name'] , $path1 )) { echo "The file ". basename($HTTP_POST_FILES['upload1']['name'])." has been sucessfully uploaded"; } else { echo "There was an error with your upload. Please try again."; } } // Upload 2 if ( $HTTP_POST_FILES['upload2']['error'] == 0 ) { $path2 = $uploadDir . basename( $HTTP_POST_FILES['upload2']['name'] ); if ( move_uploaded_file ( $HTTP_POST_FILES['upload2']['tmp_name'] , $path2 )) { echo "The file ". basename($HTTP_POST_FILES['upload2']['name'])." has been sucessfully uploaded"; } else { echo "There was an error with your upload. Please try again."; } } // Upload 3 if ( $HTTP_POST_FILES['upload3']['error'] == 0 ) { $path3 = $uploadDir . basename( $HTTP_POST_FILES['upload3']['name'] ); if ( move_uploaded_file ( $HTTP_POST_FILES['upload3']['tmp_name'] , $path3 )) { echo "The file ". basename($HTTP_POST_FILES['upload3']['name'])." has been sucessfully uploaded"; } else { echo "There was an error with your upload. Please try again."; } }}?><html> <head> <title> .::Upload::. </title> </head><body style="font-family: Arial; font-size: 10px;"><form method="post" enctype="multipart/form-data" action=""> <input type="hidden" name="MAX_FILE_SIZE" value="650000" /> File location: <input type="file" name="upload1" /><br /> File location: <input type="file" name="upload2" /><br /> File location: <input type="file" name="upload3" /><br /> <input type="submit" value="Upload" /></form></body></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8338-problem-with-uploading/#findComment-30615 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.