trican
asked on
File Upload
Hi,
Simple question, I'm trying to do a file upload and I'm having problems
upload.html
.
.
<form action="upload.php" method="post" enctype="multipart/form-da ta">
<p>Select File to upload:
<input type="file" name="uploadfile" /></p>
<p><input type="submit" name="Submit" value="Submit" /></p>
</form>
.
.
upload.php
<?
//file extension check
if (eregi('^image/p?jpeg(;.*) ?$', $_FILES['uploadedfile']['t ype']))
$extension = '.jpg';
else $extension = '.gif';
echo $extension;
$filename = $_SERVER['DOCUMENT_ROOT']. '/temp0000 1'. $extension;
if (copy($_FILES['uploadedfil e']['tmp_n ame'], $filename))
{
echo "<p>file stored successfully as $filename</p>";
}
else
{
echo "<p>Problem with file storage</p>";
}
?>
It always reports the "Problem with file storage" also the gif is always returned from the extension check.
Any help appreciated
Simple question, I'm trying to do a file upload and I'm having problems
upload.html
.
.
<form action="upload.php" method="post" enctype="multipart/form-da
<p>Select File to upload:
<input type="file" name="uploadfile" /></p>
<p><input type="submit" name="Submit" value="Submit" /></p>
</form>
.
.
upload.php
<?
//file extension check
if (eregi('^image/p?jpeg(;.*)
$extension = '.jpg';
else $extension = '.gif';
echo $extension;
$filename = $_SERVER['DOCUMENT_ROOT'].
if (copy($_FILES['uploadedfil
{
echo "<p>file stored successfully as $filename</p>";
}
else
{
echo "<p>Problem with file storage</p>";
}
?>
It always reports the "Problem with file storage" also the gif is always returned from the extension check.
Any help appreciated
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The first part is making sure the graphic file is what it claims it is by examining the $_FILES['uploadedfile']['t
I made the upload.php file really basic having just the following:
$filename = $_SERVER['DOCUMENT_ROOT'].
if (copy($_FILES['uploadedfil
{
echo "<p>file stored successfully as $filename</p>";
}
else
{
echo "<p>Problem with file storage</p>";
}
but the else condition always executes? :-(