Results 1 to 4 of 4

Thread: Uploading problem

  1. #1

    Thread Starter
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Resolved Uploading problem

    okay, so I'm trying to learn how to upload files but it isn't working.
    upload.php
    Code:
    <HTML>
    <HEAD>
    <TITLE>Upload</TITLE>
    </HEAD>
    
    <BODY>
    <FORM ACTION="xupload.php" METHOD="POST" ENCTYPE="multipart/form-data">
    <INPUT TYPE="file" NAME="uploadfile"><BR><INPUT TYPE="submit" VALUE="Upload">
    </FORM>
    </BODY>
    </HTML>
    xupload.php
    Code:
    <?
    echo "<PRE>";
    echo "Local temp file called after upload: $uploadfile\n";
    echo "original remote file called: $uploadfile_name\n";
    echo "size of the file in bytes: $uploadfile_size\n";
    echo "file type: $uploadfile_type\n";
    echo "</PRE>";
    echo "<HR>";
    
    if ($uploadfile == "") {
    	#No file was uploaded
    	header("Location: upload.php");
    	exit;
    }
    ?>
    
    
    <HTML>
    <BODY>
    
    
    <?
    if (copy($uploadfile,targetdir)) {
    	echo "File Uploaded OK";
    	#Delete Temp. File
    	unlink($uploadfile);
    } else {
    	echo "File Upload Failed";
    }
    ?>
    
    <BR><BR>
    <A HREF="upload.php">Continue</A>
    </BODY>
    </HTML>
    Last edited by Disiance; Sep 5th, 2005 at 06:40 PM.
    "I don't want to live alone until I'm married" - M.M.R.P

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Uploading problem

    Very likely, register_globals is switched off in your PHP. See here for more information:
    http://www.php.net/manual/en/feature...ad.post-method
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Uploading problem

    You should also use <?php ?> style tags rather that the generic ones. Again like register_globals, these are now turned off by default in PHP.

    Rather than turning register globals on, you should use the $_POST, $_FILES and $_GET arrays. $_POST contains variables from posted forms and $_GET contains variables form the query string and $_FILES contains any uploaded files. You simply access them by their names:
    PHP Code:
    echo($_POST['varname']);

    /* for a file */
    echo "size of the file in bytes: $_FILES['uploadfile']['size']}\n"
    See here for more info on uploading files.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4

    Thread Starter
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Re: Uploading problem

    Thank you both for your help!
    "I don't want to live alone until I'm married" - M.M.R.P

Posting Permissions

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



Click Here to Expand Forum to Full Width