I'm modifying a someone else's image upload script for a wysiwyg editor called htmlarea because it's not compatible with my version of php (4.2.2)
I have the upload script working now, but my images upload wrong. The top of any picture I upload is ok, but the bottom 3/4 of the picture is all noise. Can anyone help me?
Here's my code:
include "config.inc.php";
$endresult = "<BR><BR><font size=\"2\"><IMG SRC=\"images/success.gif\" WIDTH=\"25\" HEIGHT=\"24\" BORDER=\"0\" ALIGN=\"absmiddle\"> <B>File Was Successfully Uploaded</B></font>";
if ($file_name == "")
{
$endresult = "<BR><BR><font size=\"2\"><IMG SRC=\"images/error.gif\" WIDTH=\"25\" HEIGHT=\"24\" BORDER=\"0\" ALIGN=\"absmiddle\"> <B>Error: No file was selected</B></font>";
}
else
{
if(file_exists("$absolute_path/$file_name"))
{
$endresult = "<font size=\"2\"><IMG SRC=\"images/error.gif\" WIDTH=\"25\" HEIGHT=\"24\" BORDER=\"0\" ALIGN=\"absmiddle\"> <B>Error: A file with the same name already exists</B></font>";
}
else
{
if (($size_limit == "yes") && ($limit_size < $file_size))
{
$endresult = "<BR><BR><font size=\"2\"><IMG SRC=\"images/error.gif\" WIDTH=\"25\" HEIGHT=\"24\" BORDER=\"0\" ALIGN=\"absmiddle\"> <B>Error: File exceeds allowed size</B></font>";
}
else
{
$ext = strrchr($file_name,'.');
if (($limit_ext == "yes") && (!in_array($ext,$extensions)))
{
$endresult = "<BR><BR><font size=\"2\"><IMG SRC=\"images/error.gif\" WIDTH=\"25\" HEIGHT=\"24\" BORDER=\"0\" ALIGN=\"absmiddle\"> <B>Error: Files of this type are not allowed</B></font>";
}
else
{
echo "absolutepath: " .$absolute_path;
echo "<br />filename: " .$file_name;
echo "<br />tempfile: ".$FILES['file']['tmp_name'];
//@copy($myFile, "$absolute_path/$file_name") or $endresult = "<font size=\"2\"><IMG SRC=\"images/error.gif\" WIDTH=\"25\" HEIGHT=\"24\" BORDER=\"0\" ALIGN=\"absmiddle\"> <B>Error: Couldn't copy file to server</B></font>";
@copy($FILES["file"]["tmp_name"], "$absolute_path/$file_name") or $endresult = "<font size=\"2\"><IMG SRC=\"images/error.gif\" WIDTH=\"25\" HEIGHT=\"24\" BORDER=\"0\" ALIGN=\"absmiddle\"> <B>Error: Couldn't copy file to server</B></font>";
}
}
}
}