Karen
|
| Posted: 01/17/2003, 11:47 PM |
|
Can anyone give me a clue why the images that I upload using the solution in the tips/articles have the following appended to the beginning of the files?
Content-Type: image/gif
With this, the image cannot be displayed. Pls help!
TIA.
|
|
|
 |
feha
|
| Posted: 01/18/2003, 3:16 AM |
|
Instead of file name You are geting filetype, please check your code ...
regards
feha
[www.vision.to]
|
|
|
 |
Karen
|
| Posted: 01/18/2003, 3:52 PM |
|
I'm getting the filename for sure and the file is being uploaded. The only problem is the extra appended to the file. The rest of the file contents are still there. How did the extra come about? I did not code anything to do with file type.
|
|
|
 |
feha
|
| Posted: 01/19/2003, 2:37 AM |
|
I can't answer before I see the code ...
regards
feha
|
|
|
 |
Karen
|
| Posted: 01/19/2003, 3:44 PM |
|
here's what I've done:
in the form footer (of the form to upload file):
<FORM ENCTYPE="multipart/form-data" ACTION="Admin_Upload.php" METHOD=POST>
Or attach file: <INPUT NAME="myfile" TYPE="file">
<INPUT TYPE="hidden" NAME="code" VALUE="{value}">
<INPUT TYPE="submit" VALUE="Attach File">
</FORM>
in Admin_Upload.php:
$tmpfile = "images/products/".$myfile_name;
if(!file_exists($tmpfile))
{
copy($myfile,$tmpfile);
}
else
{
unlink($tmpfile);
copy($myfile,$tmpfile);
}
this is only the part to upload the file, I also have the code to update the database but that is not relevant. do you see any problem? thanx.
|
|
|
 |
feha
|
| Posted: 01/20/2003, 3:45 AM |
|
I can't see anything wrong in Your code ...
I have Included My own developed code for You just clip and paste the code bellow to your project on the footer of the form where you want it ...
(Change path for the directory ans if in LINUX/UNIX CHMOD Your dir 777 ...)
--------- clip bellow -----
<?
//free for use by www.vision.to leave this intact thank you
$sizelim = "yes";//file
$file_type1 = "image/pjpeg";
$file_type2 = "image/jpeg";
$file_type3 = "image/gif";
$file_type4 = "image/png";
$max_pic_size = "120000";//File size
$log_report.="";
// START UPLOAD -------------------------------------------
//PICTURE--------------------------------------------------
if ($pic) {
if (($sizelim == "yes") && ($pic_size > $max_pic_size)) {
$log_report.="<br><b>$pic_name was too big</b><br>";
}
else
{
if (($pic_type == $file_type1) or ($pic_type == $file_type2) or ($pic_type == $file_type3) or ($pic_type == $file_type4))
{
@copy($pic, "images/pic/$pic_name") or $log_report.= "<br><b>Couldn't copy $pic_name to server</b><br>";
if (file_exists("images/pic/$pic_name"))
{
chmod("images/pic/$pic_name",0777);
$pic_name_1 = "images/pic/$pic_name";
$image_size = getimagesize($pic_name_1);
$img_width = (($image_size[0]));
$img_height = (($image_size[1]));
if (($img_width > 800 or $img_height > 800))
{
$log_report.= "<br><b>Image SIZE was too big W:$img_width H: $img_height <br>MAX: 800x800 for IMAGE size </b><br>";
unlink("images/pic/$pic_name");
}
else
{
$log_report.="<br> <b>The $pic_name [$img_width x $img_height]<br>has been uploaded in to [pic] dir</b> <br>";
}
}
}
}
echo "<font face=\"verdana\" size=\"1\" color=\"red\" >$log_report</font>";$log_report="";
}
// END PICTURE--------------------------------------------------
// END UPLOAD ------------------------------------------------
?>
<center>
<form method="POST" ACTION="<?=$sFileName?>" enctype="multipart/form-data">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="150">
<tr>
<td><hr></td>
</tr>
<tr>
<td width="33%"> <font size="1" face="verdana" >Pic Max 120kb,(800x800)</font> </td>
</tr>
<tr>
<td width="33%"> <input type="file" name="pic" size="20">
</td>
</tr>
<tr>
<td>
<center><br><input type="submit" name="submit" value=" :: Upload :: "></center>
</td>
</tr>
</table>
</form>
</center>
---- end clip -----
regards
feha
[www.vision.to]
|
|
|
 |
Karen
|
| Posted: 01/22/2003, 1:36 AM |
|
Hi Feha,
I can't use your code in my project just like that as I have extra codes after the file is uploaded successfully. But I would like to try the upload part just to see if the file uploaded has the same results and that would help me pinpoint the problem.
What should I replace sFileName with in this line of your code?
<form method="POST" ACTION="<?=$sFileName?>"
I get lots of codes and error msg displayed on the footer of the page that I open to upload. Do I place the whole thing in the form footer?
Thanx for your help.
|
|
|
 |
feha
|
| Posted: 01/22/2003, 3:27 AM |
|
Yes You have to place the whole code in to the footer of form (not a whole page)
and this acts as an upload script with the form within the same page without the need for external upload script ...
(I haven't tested this with TEMPLATES but this works on all my projects without problems)
<form method="POST" ACTION="<?=$sFileName?>"
the $sFileName represents name of actual page, but if you decide to use upload with separate script/page than you put the name of that page...
as:
<form method="POST" ACTION="xxxxx.php"> ...
I hope this helps ...
You can devide the script in two parts...
The first one is the php upload and second one is the form it self ...
(I didn't like to use to many external scripts so I decided to make it all in one page )
regards
feha
[www.vision.to]
|
|
|
 |