Jump to content


Photo

simple upload script not working or giving any error... help!!


  • Please log in to reply
7 replies to this topic

#1 just-j

just-j
  • Members
  • PipPipPip
  • Advanced Member
  • 52 posts

Posted 22 September 2006 - 09:40 PM

html code for the form
<form action="uploader.php" method="post"><br>
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
Type (or select) Filename: <input type="file" name="uploadFile">
<input type="submit" value="Upload File">
</form>

and this is the PHP code...
<?php
if ( move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'],
       "tbbc/mp3z/{$_FILES['uploadFile'] ['name']}")  )
      {  echo "The file has been successfully uploaded";
       }
else
      {
        switch ($_FILES['uploadFile'] ['error'])
         {  case 1:
                   echo " The file is bigger than this PHP installation allows";
                   break;
            case 2:
                   echo " The file is bigger than this form allows";
                   break;
            case 3:
                   echo " Only part of the file was uploaded";
                   break;
            case 4:
                   echo " No file was uploaded";
                   break;
         }
       }
?>

it dosent return anything when i click the upload button on the form..  no error and no success...  just shows a blank page.  im also running wamp5 if that helps.

#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 22 September 2006 - 09:45 PM

in the form tag you need the enctype
<form method='post' action='uploader.php' enctype='multipart/form-data'>
Tell me the problem, I will try tell you the solution

#3 just-j

just-j
  • Members
  • PipPipPip
  • Advanced Member
  • 52 posts

Posted 22 September 2006 - 11:50 PM

ok  that solved the problem,  but now i get this error..
=================

Warning: move_uploaded_file(tbbc/mp3z/07 Way Up Top.wma) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\wamp5\www\tbbc\uploader.php on line 11

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'c:/wamp5/tmp\phpA39.tmp' to 'tbbc/mp3z/07 Way Up Top.wma' in C:\wamp5\www\tbbc\uploader.php on line 11

=================
the directory mp3z is in the same directory as the .php file

#4 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 23 September 2006 - 01:04 AM

I bet it's the permissions of that directory... It probably needs to be globally writable. you can try using php's chmod(dirname,0777);



#5 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 23 September 2006 - 01:08 AM

but he is using WAMP localhost by the looks of it, which dont have or require chmods

I notice there are spaces in the file names tho, tut tut
Tell me the problem, I will try tell you the solution

#6 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 23 September 2006 - 01:16 AM

okay, try this...

move_uploaded_file($_FILES['uploadFile']['tmp_name'], realpath(".")."/". $_FILES['uploadFile'] ['name']);


#7 just-j

just-j
  • Members
  • PipPipPip
  • Advanced Member
  • 52 posts

Posted 23 September 2006 - 06:42 PM

ok that worked  but what do i have to add to make it move the file to the "mp3z" directory that is a subdirectory where the webpage is.  right now it moves the file to the webpage directory

web page directory is /tbbc  and i need the file to move to /tbbc/mp3z

#8 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 23 September 2006 - 06:46 PM

move_uploaded_file($_FILES['uploadFile']['tmp_name'], realpath(".")."/mp3z/". $_FILES['uploadFile'] ['name']);





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users