Jump to content

upload file problem......need help


desmond_ckl

Recommended Posts

hello everyone....i am new for this script, hope u guys able to help me. Thank you in advance! :-*

 

im using xampp for localhost, all .php file i place it in xampp\htdocs ( i create a uploads folder outside the htdocs, c:\xampp\uploads)

 

This is the error message i get after i upload the file:

Notice: Undefined variable: FILES in C:\xampp\htdocs\upload_file.php on line 15

 

Warning: move_uploaded_file() [function.move-uploaded-file]: The second argument to copy() function cannot be a directory in C:\xampp\htdocs\upload_file.php on line 15

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\tmp\phpAE.tmp' to '../uploads/' in C:\xampp\htdocs\upload_file.php on line 15

Your file could not be uploaded because: Something unforeseen happened..

 

 

following is my upload_file.php script , i highlighted on line 15:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Upload a File</title>

</head>

 

<body>

<?php  ///Script - 11.4 - upload_file.php

/* This script displays and handles an HTML form. this script takes a file upload and stored it on the servers */

 

if(isset($_POST['submitted'])) { //Handle the form

 

//Try to move the upload file:

if (move_uploaded_file ($_FILES['thefile']['tmp_name'],"../uploads/{$FILES['thefile']['name']}")){

 

print '<p>Your file has been uploaded.</p>';

 

}else {  //problem!!

 

print '<p style="color:red;">Your file could not be uploaded because: ';

 

///print a message based upon the error:

switch ($_FILES['thefile']['error']) {

case 1:

print 'The file exceeds the upload_max_filesize setting in php.ini';

break;

case 2:

print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form';

break;

case 3:

print 'The file was only partially uploaded';

break;

case 4:

print 'No file was uploaded';

break;

case 6:

print 'The temporary folder does not exist.';

break;

default:

print 'Something unforeseen happened.';

break;

}

 

 

print '.</p>';  /////complete the paragraph.

 

} // End of move_uploaded_file()IF

 

} // End of submission IF

 

//Leave PHP and display the form:

?>

 

 

 

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

<p>Upload a file using this form:</p>

    <input type="hidden" name="MAX_FILE_SIZE" value="30000" />

    <p><input type="file" name="thefile" /></p>

    <p><input type="submit" name="submit" value="Upload This File" /></p>

    <input type="hidden" name="submitted" value="true" />

</form>

 

 

</body>

</html>

 

Link to comment
Share on other sites

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.