Jump to content

Recommended Posts

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:

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

and uploader.php

<?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>
<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 $_FILES['file']['name']; ?>">Click here to view the file</a>
</body></html>

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!
Link to comment
https://forums.phpfreaks.com/topic/3828-notice-undefined-index-file-in/
Share on other sites

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.