iamali Posted March 3, 2006 Share Posted March 3, 2006 Does anyone know what would cause this error: [i]Notice: Undefined index: file in C:\Inetpub\wwwroot\Upload\uploader3.php on line 2No file specified[/i]with these files for uploading images:uploader.htm<html><head><title>File Uploader</title></head><body><h3>File Upload</h3>Select a file to upload:<br><form action="uploader.php" method="post" enctype="multipart/form-data"><input type="file" name="file" size="45"><br><input type="submit" value="Upload File"></form></body></html>and,uploader.php<?phpif( $_FILES['file']['name'] != "" ){copy ( $_FILES['file']['tmp_name'],"C:/Inetpub/wwwroot/Upload/" . $_FILES['file']['name'] )or die( "Could not copy file" );}else{ die( "No file specified" ); }?><html><head><title>Upload Complete</title></head><body><h3>File Upload Succeeded...</h3><ul><li>Sent: <?php echo $_FILES['file']['name']; ?><li>Size: <?php echo $_FILES['file']['size']; ?> bytes<li>Type: <?php echo $_FILES['file']['type']; ?></ul><a href="<?php echo "C:/Inetpub/wwwroot/Upload/".$_FILES['file']['name']; ?>"><img src="<?php echo "C:/Inetpub/wwwroot/Upload/".$_FILES['file']['name']; ?>" height="200"></a></body></html>Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/3965-more-errors/ Share on other sites More sharing options...
wildteen88 Posted March 3, 2006 Share Posted March 3, 2006 Change [code]if( $_FILES['file']['name'] != "" )[/code] to [code]if(isset($_FILES['file']['name']) && !empty($_FILES['file']['name']) )[/code]Put simply $_FILES['file'] array isn't set and so you recieve the notification message, the above code should stop this message form appearing as you are doing proper validation on your uploaded files, which is checing that $_FILES['file'] array is set and secoundly it isnt empty. Quote Link to comment https://forums.phpfreaks.com/topic/3965-more-errors/#findComment-13927 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.