I am uploading .Jpegs and GIFS but they end up being all messed up when
I try to view them after a file transfer.

However, txt file transfers work ok.  Someone told me this is because
images need to be transfered as binary files, not ascii files (like
txt).

Is this true, and if so, how do I correct for this?  Thanks.

SOURCE CODE _____________________________________________

<%
if ($Action == "Submit")
   {
     /* define and list important vars */
     $Userfile = $HTTP_POST_FILES['Userfile']['name'];
     $Type = $HTTP_POST_FILES['Userfile']['type'];
     $Size = $HTTP_POST_FILES[Userfile][size];
     $TempLoc = $HTTP_POST_FILES[Userfile][tmp_name];
     $FinalLoc = "website_com/uploads/$Userfile";
     echo " File: $Userfile | Type: $Type | Size: $Size | TempLoc:
$TempLoc <br> FinalLoc: $FinalLoc <br>";

  /* confirm file not too big and permitted type */
  if ($Size > 200000) $FileError = "File size greater than 200 kb.";
     if (($Type != "text/plain") && ($Type != "image/jpeg") && ($Type !=
"image/gif") && ($Type != "image/pjpeg")) $FileError = "File not correct
type (txt, jpg, gif only).";

     /* move file to final destination on server if no errors */
     if (!$FileError) move_uploaded_file($TempLoc, $FinalLoc);
   }
else
   { echo " Load page"; }
if ($FileError) echo "FILE NOT ACCEPTED: $FileError";
%>
<html>
<head>
<title>PHP Send File</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body bgcolor="#FFFFFF" text="#000000">
<p>Send me a file!!! Testing page.... 200 kbytes max. Text, Jpeg, and
Gif's only.</p>
<form enctype="multipart/form-data" action="sendfile.php" method="post">

  <p>
    <input type="hidden" name="MAX_FILE_SIZE" value="2000000">
    Send this file:
    <input name="Userfile" type="file">
  </p>
  <input type="submit" name="Action" value="Submit">
</form>
<%
echo "Browser and OS: $HTTP_USER_AGENT <br>IP Addr: $REMOTE_ADDR";
%>
<p><a href="uploads/">View</a> the upload directory to see if your file
is there.</p>
<p><a href="sendfile.txt">View</a> this page's full source code.</p>
</body>
</html>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to