Jump to content


Notice: Undefined index: file in...

  • Please log in to reply
2 replies to this topic

#1 iamali

  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 01 March 2006 - 02:05 PM

Been having a few problems, I'm using PHP 5 and IIS 5

I'm following a tutorial in a book for creating an uploading facility. The two files are:


<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="multiparty/form-data">
<input type="file" name="file" size="45">
<input type="submit" value="Upload File">

and uploader.php

if( $_FILES['file']['name'] != "" )
copy ( $_FILES['file']['tmp_name'],
"C:/Inetpub/wwwroot/" . $_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>
<li>Sent: <?php echo $_FILES['file']['name']; ?>
<li>Size: <?php echo $_FILES['file']['size']; ?> bytes
<li>Type: <?php echo $_FILES['file']['type']; ?>

<a href="<?php echo $_FILES['file']['name']; ?>">Click here to view the file</a>

uploader.htm works fine but when I click upload it gives me this error:

"Notice: Undefined index: file in C:\Inetpub\wwwroot\uploader.php on line 2
No file specified"

see image also:
[a href=\"http://groups.msn.com/_Secure/0RADhAr0UCNb7c1bIEGOHeB35SQeNXnKIm1ZDxw7esEuiTTi1Xa4vYAagZnCPULWTqvXVIUz5LfRqCdZ6iuPVJtzNNGibh5P9QsxxeUkvj1s/uploaderphp.JPG?dc=4675562318333745343\" target=\"_blank\"]http://groups.msn.com/_Secure/0RADhAr0UCNb...562318333745343[/a]

Does anyone have any idea why it's doing this? I got this tutorial to work last week and for no reason it's stopped working :-( Thanks!

#2 shocker-z

  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 01 March 2006 - 02:14 PM

I *think* this is because u used

<form action="uploader.php" method="post" enctype="multiparty/form-data">

but ment to be

<form action="uploader.php" method="post" enctype="multipart/form-data">

So that is multipart instead of multiparty.. Give that a go and see if that solves it :0
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 iamali

  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 01 March 2006 - 02:21 PM

hahaha thankyou so much, it was that!
*slaps forehead*

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users