Page 1 of 1

Help uploading .dwg or .swf

Posted: Fri Jan 02, 2004 11:24 pm
by mac++
I´m installing apache server under winxp I test some scrip to upload files to the server and work fine but only with .gif and .jpeg files but when I tried change the extencion to .dwg or .swf the scrip doesn´t work I like to know if I need to add the lines AddType extencion/mime to the httpd.conf or is not necessary I tried a lot of mime extencion but i have the same problem I really need yours help thaks.



Code: Select all

<?php

$maxsize = "300000";
$path = "/";
$uploads = $_REQUEST['uploads'];
$uploadedFile = $_FILES['uploadedFile'];
$fileName = $_POST['fileName'];

if(@$uploads <= 1)
{
$uploads = 5;
}
$fields = $uploads + $uploads;

for($n = 0; $n < $uploads; $n++)
{
if(@is_array($uploadedFile) && $uploadedFile['tmp_name'][$n] != "none"
&& $uploadedFile['size'][$n] != 0 && $uploadedFile['type'][$n] == 'image/vnd.dwg'
&& is_uploaded_file($uploadedFile['tmp_name'][$n]))
{
move_uploaded_file($uploadedFile['tmp_name'][$n], $path.$uploadedFile['name'][$n]);
rename($path.$uploadedFile['name'][$n], $path.$fileName[$n]);
if(file_exists("$path$fileName[$n]"))
{
print("upload successful for $fileName[$n] - $uploadedFile_size[$n] bytes<br>\n");
}
else
{
print("error: upload failed<br>\n");
}
}
}

print("<form action="$PHP_SELF" method="POST" enctype="multipart/form-data">\n");
print("<input type="hidden" name="MAX_FILE_SIZE" value="$maxsize">\n");
print("<table border="0" cellpadding="0" cellspacing="3"><tr><td>\n");
print("<b>Name:</b></td><td>\n");
print("<b>File Location:</b></td></tr>\n");

for($i = 1; $i <= $uploads; $i++)
{
print("<tr><td><input type="text" name="fileName[]" value="example$i.jpg" size="13"></td><td>\n");
print("<input type="file" name="uploadedFile[]" size="25"></td></tr>\n");
}

print("<tr><td align="center"><input type="submit" value="UPLOAD"></td><td>\n");
print("<a href="$PHP_SELF?uploads=$fields">More Upload Fields</a></td></tr>");
print("</table>\n");
print("</form>\n");

?>

Posted: Sat Jan 03, 2004 3:47 pm
by DuFF
First, make sure you are using the correct MIME type. You can figure it out by echoing the MIME type out in the error message, like this:

Code: Select all

<?php
else
{
print("error: upload failed<br>\nThe file's mimetype was $uploadedFile['type'][$n]<br>\n");
}
?>