problem w/ image upload
Posted: Sat Jun 03, 2006 4:39 pm
Ok,
I went crazy here, I want to upload image and I used code that was working fone im my other project but now it aint working...
it gives me this error:
I see thta pemission denied, but tempdatafile should have proper permissions because it works on diferent project, and i set all users to have write read and execute permissions for the final directory. I was tying to run it on both Win/ Apache and FreeBSD/ Apache nothing is working
Can some one help?
Here is the code:
I went crazy here, I want to upload image and I used code that was working fone im my other project but now it aint working...
it gives me this error:
Code: Select all
Warning: move_uploaded_file(../img_banners//tmp/phprzLkfI_a34230bc61b18538024986d442e6b45b.jpg): failed to open stream: No such file or directory in /usr/local/psa/home/vhosts/lrcommunications.net/httpdocs/uc/admin/frontpage_banner.php on line 89
Warning: move_uploaded_file(): Unable to move '/tmp/phprzLkfI' to '../img_banners//tmp/phprzLkfI_a34230bc61b18538024986d442e6b45b.jpg' in /usr/local/psa/home/vhosts/lrcommunications.net/httpdocs/uc/admin/frontpage_banner.php on line 89
Error uploading fileCan some one help?
Here is the code:
Code: Select all
if(isset($get_banner)|| isset($send_file)){
if(isset($send_file)){
$uploaddir = '../img_banners/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
$ext = substr(strrchr($_FILES['userfile']['name'], '.'), 1);
$new_name = $userfile. "_". md5($userfile).".$ext";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], "../img_banners/".$new_name)) {
echo "File uploaded";
} else {
echo "Error uploading file";
}
}
?>
<form method="POST" enctype="multipart/form-data" action="<? echo $PHP_SELF; ?>">
<div align="center">
<div align="center">
<b><? echo $event; ?></b><br>
<table border="0" width="419" style="border-collapse: collapse">
<tr>
<td colspan="2" bgcolor="#008080">
<p align="center"><b>
<font face="Arial" size="2" color="#FFFFFF">Already Uploaded</font></b></td>
</tr>
<tr>
<td width="141" bgcolor="#C0C0C0">File Name: </td>
<td width="262" bgcolor="#C0C0C0"> </td>
</tr>
</table>
</div>
<br>
<table border="0" width="419" style="border-collapse: collapse">
<tr>
<td colspan="2" bgcolor="#008080">
<p align="center"><b>
<font size="2" face="Arial" color="#FFFFFF">Upload Front Page
Banner</font></b></td>
</tr>
<tr>
<td width="141" bgcolor="#C0C0C0">Select File: </td>
<td width="262" bgcolor="#C0C0C0"><input type="file" name="userfile" size="20"></td>
</tr>
<tr>
<td width="141" bgcolor="#C0C0C0"> </td>
<td width="262" bgcolor="#C0C0C0"><input type="submit" name="send_file" value="Upload Banner"></td>
</tr>
</table>
</div>
<input type="hidden" name="event" value="<? echo $event; ?>">
<input type="hidden" name="event_id" value="<? echo $event_id?>">
</form>
<?
}
?>