Please help - File Uploads, 2nd try

From: Date: Sat, 24 Feb 2001 21:43:54 +0000
Subject: Please help - File Uploads, 2nd try
Groups: php.general 
Request: Send a blank email to php-general+get-41512@lists.php.net to get a copy of this message
I upgraded my web server and now file uploads don't work. A test script is listed below. It puts the file on the server, but the file has Content-Type: image/pjpeg^M ^M pre-pended to it, thus breaking the file. Do you know why it's doing this and how to fix it? -Ed <?php global $HTTP_POST_VARS; global $REQUEST_URI; if (empty($HTTP_POST_VARS)) { # Display form ?> <h3>File Upload Test</h3> <form method="post" enctype="multipart/form-data" action="<?php echo $REQUEST_URI;?>"> <input type="hidden" name="max_file_size" value="35000000"> <table border="0" callpadding="0" cellspacing="0"> <tr> <td align=right width=125> <font size=2 face="Verdana, Arial"><b> Upload: &nbsp; </b></font> </td> <td> <input type="file" name="uploadedfile" size="39"> </td> </tr> <tr> <td colspan="2" align=right> <input type="submit" value="UPLOAD"> </td> </tr> </table> </form> <? } else { # process form global $uploadedfile_name; global $uploadedfile; # replacing spaces with the _ symbol $Filename = ereg_replace(" ", "_", $uploadedfile_name); # move the uploaded file to the archive # I put <path to files> here for display purposes only $Location = "<path to files>/htdocs/attachments/test/" . $Filename; #copy($uploadedfile, $Location); move_uploaded_file($uploadedfile, $Location); print "File upload processed.<br><br><br>"; print "<a href='/attachments/test/$Filename'>Link to file</a><br>"; } ?>

« previous php.general (#41512) next »