sanjdhiman
Programmer
Hi there quick question want to upload an image into a directory suing windows XP home edition mySQL and apache in the usual fashion.
Im using the following script once the user has on a previous form chosen the file to upload.
<?
if ($userfile=="none"
{
echo '<td class=form> Problem, no file uploaded </td>';
exit;
}
if ($userfile_size==0)
{
echo '<td class=form> Problem, uploaded file is of zero length </td>';
exit;
}
if (!is_uploaded_file($userfile))
{
echo '<td class=form> Problem, possible file upload attack </td>';
exit;
}
$upfile= "$DOCUMENT_ROOT/php/agents/$valid_agent/" . $userfile_name;
if( !copy($userfile, $upfile));
{
echo "<td class=form>Problem: Could not move file into directory</td>";
exit;
}
echo "<td class=form>File uploaded successfully<br><br></td>";
$fp = fopen($upfile, "r"
;
$contents = fread ($fp, filesize($upfile));
fclose ($fp);
$contents = strip_tags($contents);
$fp = fopen($upfile, "w"
;
fwrite($fp, $contents);
fclose($fp);
echo "<tr><td class=form>Preview of uploaded file contents <br><hr></td></tr>";
echo $contents;
echo "<td><br><hr></td>";
?>
The problem lies when this page is displayed it says that it hasnt uploaded the file e.g. it returns false when the if (!copy....) section of the script above.
thanks in advance
sanj
Im using the following script once the user has on a previous form chosen the file to upload.
<?
if ($userfile=="none"
{
echo '<td class=form> Problem, no file uploaded </td>';
exit;
}
if ($userfile_size==0)
{
echo '<td class=form> Problem, uploaded file is of zero length </td>';
exit;
}
if (!is_uploaded_file($userfile))
{
echo '<td class=form> Problem, possible file upload attack </td>';
exit;
}
$upfile= "$DOCUMENT_ROOT/php/agents/$valid_agent/" . $userfile_name;
if( !copy($userfile, $upfile));
{
echo "<td class=form>Problem: Could not move file into directory</td>";
exit;
}
echo "<td class=form>File uploaded successfully<br><br></td>";
$fp = fopen($upfile, "r"
$contents = fread ($fp, filesize($upfile));
fclose ($fp);
$contents = strip_tags($contents);
$fp = fopen($upfile, "w"
fwrite($fp, $contents);
fclose($fp);
echo "<tr><td class=form>Preview of uploaded file contents <br><hr></td></tr>";
echo $contents;
echo "<td><br><hr></td>";
?>
The problem lies when this page is displayed it says that it hasnt uploaded the file e.g. it returns false when the if (!copy....) section of the script above.
thanks in advance
sanj