View Single Post
  #1 (permalink)  
Old May 20th, 2006, 11:04
DavidinLondon DavidinLondon is offline
Junior Member
Join Date: Jul 2004
Location: Bulgaria
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Problem with image in Mozilla ?? please help

Hi -

i have written a little script that displays the image that is about to be uploaded.
it works great in IE but not in Mozilla Firefox.

in fact BOTH the control image and the upload image are shown as broken links in Mozilla.

Does anyone know how to fix this ??

Here is the code

Code: Select all
<?php 
/* upload.php
*
*/

if (!isset($_POST[upload])) {
$message1 = "Enter File Path";
$message2 = " Now "; 
include ("upload_form.php");
} // endif
else {
if($_FILES['pix']['tmp_name'] == "none") {
$message1 = "File did not successfully upload.";
$message2 = "Check the file size. Must be less than 250K";
include ("upload_form.php");
exit();
} // endif

if(!ereg("image",$_FILES['pix']['type'])) {
$message1 = "File is not a picture file.";
$message2 = "Please try a different file.";
include ("upload_form.php");
exit();
} // endif

else { 
$destination = 'd:\Web\images'."\\".$_FILES['pix']['name'];
$temp_file = $_FILES['pix']['tmp_name'];
move_uploaded_file($temp_file,$destination);
$message1 = "File has been successfully uploaded.";
$message2 = "CONGRATULATIONS !"; 
include ("upload_form.php");
exit(); 
} // end else
} // end else

?>
----------------------------------------------------

and the form :



Code: Select all
<?php 
/* upload_form.php
*
*/

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- Upload_form.inc
Description : displays the a form for uploading data
-->
<html>
<head>
<title>Untitled</title>

<script language="JavaScript" type="text/javascript">
<!--
function changeSrc1(who){
img=who.replace(who.substring(0,1),'file:///'+who.substring(0,1));//add 'file:///' before the drive letter
img=img.replace(/\\/g,'/');//replace all backslashes with forward slashes
document.getElementById('pre_veiw').src=img;
} // end of function
-->
</script>

</head>
<body>

<div style='position:absolute; left:20px; top:60px'>
<form name = 'main' enctype ="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name ="MAX FILE SIZE" value="500000">
<table width="400px" border="0" cellspacing="0" cellpadding="1">
<tr>
<td>Picture file path: </td> 
<td>
<input type="file" id="x_pix1" size="50" onchange="changeSrc1(this.value)" 
name="pix" value = "<?php echo $x_pix1 ?>">
</td></tr>

<tr><td>
<input type="submit" name="upload" value="Upload Picture">
</td></tr>
</table>
</form>
</div>

<div id='Previewer' style='position:absolute; left:30px; top:200px' >
<img src="file:///D:/Web/images/control.jpg" border="0">
<img id="pre_veiw" width="120" height="120" />
<br>
- - - Picture 1 - - -
</div>

<div style='position:absolute; left:200px; top:300px'>
<?php echo $message1 ?><br>
<?php echo $message2 ?><br>
</div>

</body>
</html>

Last edited by herkalees; May 20th, 2006 at 16:03.
Reply With Quote