What is wrong, when I am not able to get image upload working in ISP. They have linux,apache and PHP4. Client(my home computer) have win2000 and IE5. I try to upload the files in uploads directory. Problem message points to copy line. I keep having the following problem message:
Warning: Unable to open 'C:\Documents and Settings\Juha\My Documents\My Pictures\Tapani20kyykky.jpg' for reading: No such file or directory in /biz/mydomain.fi/html/admin/upload3.php on line 12
My code:
<?php
include("db_functions.php");
include("functions.php");
db_open();
if ($submit<>"") {
for ($i = 1; $i <= 2; $i++) {
if ($file[$i]<>"") {
$filename="uploads/img".rand(1,9999).".jpg";
if (copy($file[$i],dirname($PATH_TRANSLATED).$filename)) {
mysql_query("insert into kuva (osoite,selite) values ('".$filename."','".$file_text[$i]."')") or
$id=mysql_insert_id();
$sql="insert into kuva_kohteet (kuva_id,kohde_tyyppi,kohde_id) values (".$id.",1,".$kansio.")";
//print $sql."<br>";
mysql_query($sql) or print "failure in upload<br>";
print "image ".$i." upload succeeded - type was ";
} else { print "image $i upload failed<br>";}
//unlink($file[$i]);
}
}
}
?>
<head>
<title>otsikko</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<form type="multipart/form-data" name="form1" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="120">
<table>
<tr><td height="55" valign="top">Kansio: </td><td valign="top"><?php dropDown("kansio",$dropdown,0) ?></td></tr>
<?php for ($i=1;$i<=2;$i++): ?>
<tr><td width="55">Kuva : </td><td valign="top"><input type="file" size="40" name="file[<?php echo $i ?>]"></td></tr>
<tr><td width="55" height="50" valign="top">Teksti : </td><td valign="top"><input type="text" size="55" name="file_text[<?php echo $i ?>]"></td></tr>
<?php endfor ?>
<tr><td><input type="submit" name="submit" value="tallenna kuvat"></td></tr>
</table>
</form>
</body>
Upload is allowed in ISP.