SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php upload file functions

    Hi,

    I am writing a PHP script to upload images and am testing it locally on my machine with Abyss X1 webserver.

    The following is currently at the top of the script, so I could see if the file was uploading properly. The thing is, it NEVER prints 'moo'!!!

    Code:
    if ($uploadedfile) { 
       echo "moo"; 
       }
    Here is the form

    Code:
    <form action="uploadimage.php" method="post" enctype="multipart/form-data"> 
      <table width="100%" border="0" cellpadding="2" cellspacing="0" class="txt"> 
    	<tr valign="top"> 
    	  <td>File:</td> 
    	  <td><input name="uploadedfile" type="file" class="txtform"></td> 
    	</tr> 
    	<tr> 
    	  <td>&nbsp;</td> 
    	  <td><input name="textid" type="hidden" id="textid" value="<?=$HTTP_GET_VARS[textid]?>"> 
    		<input name="submit" type="submit" class="txtform" id="submit" value="Submit"></td> 
    	</tr> 
      </table> 
    </form>
    is there somthing wrong with my code???

    Thanks
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  2. #2
    SitePoint Addict Mo Money's Avatar
    Join Date
    Nov 2002
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    umm. We need more information! are you even trying to upload the file using php? like copy() or move_file_to() ?? MORE INFO!
    AbcArcade.com - free internet games!

  3. #3
    SitePoint Zealot LiamW's Avatar
    Join Date
    Mar 2003
    Location
    Hamilton, Ontario
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to use the $_FILES array on file.

    http://php.net/manual/en/features.file-upload.php

  4. #4
    As the name suggests... trickie's Avatar
    Join Date
    Jul 2002
    Location
    Melbourne, Australia
    Posts
    678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You also need to specify a hiden field in the form, that 'suggests' the max file size.

    Read the link the previous post.

  5. #5
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You also need to specify a hiden field in the form, that 'suggests' the max file size.
    This is optional, and I just checked to make sure.

    The problem was I wasn;t using the array, thanks LiamW!

    print_r($_FILES);
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  6. #6
    SitePoint Enthusiast Powerlord's Avatar
    Join Date
    May 2003
    Location
    Mason, MI, USA
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by LiamW
    You need to use the $_FILES array on file.

    http://php.net/manual/en/features.file-upload.php
    ...unless you're using PHP < 4.1.0, in which case you need to use $HTTP_POST_FILES.

    I seem to recall that there was a major issue with file uploads versions prior to 4.2, though.
    Ross Bemrose,
    Independant MySQL/Perl/PHP Developer


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •