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
https://forums.phpfreaks.com/topic/230184-upload-file-problemneed-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.