On my local apache server, the code works fine, online the upload code produces this error:
Warning: Unable to open 'D:\Websites\folder\file.jpg' for reading: No such file or directory in /mysite/www/manage/submit.php on line 216
Error uploading the file
here is the code for the upload:
function upload_form($message){
if (isset($message)) echo $message;
@$big=$_POST["big"];
@$small=$_POST["small"];
@$smallest=$_POST["smallest"];
@$title=$_POST["title"];
@$description=$_POST["description"];
@$artist=$_POST["artist"];
echo "
<form name='form1' method='post' action='submit.php' enctype='multipart/form-data'>
<table width='400' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td>Artwork Submittion</td>
</tr>
<tr>
<td>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='27%'>Title:</td>
<td width='73%'>
<input type='text' name='title' value='$title'>
</td>
</tr>
<tr>
<td width='27%'>Artist:</td>
<td width='73%'>
<input type='text' name='artist' value='$artist'>
</td>
</tr>
<tr>
<td width='27%'>50 x 50:</td>
<td width='73%'>
<input type='file' name='smallest' value='$smallest'>
</td>
</tr>
<tr>
<td width='27%'>160 x 120:</td>
<td width='73%'>
<input type='file' name='small' value='$small'>
</td>
</tr>
<tr>
<td width='27%'>Bigone:</td>
<td width='73%'>
<input type='file' name='big' value='$big'>
</td>
</tr>
<tr>
<td width='27%'>Description</td>
<td width='73%'>
<textarea name='description' cols='40' rows='10' wrap='VIRTUAL'> $description</textarea>
</td>
</tr>
<tr>
<td width='27%'> </td>
<td width='73%'>
<input type='submit' name='Submit' value='Submit'>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<input type=hidden name='do' value='write'>
</form><br>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td><b><font color='#990000'>PLEASE NOTE!</font></b></td>
</tr>
<tr>
<td>
<p>NAME YOUR FILES YOURNAME_TITLE, KEEP YOUR TITLES UNIQUE! </p>
</td>
</tr>
</table>
";
}
function writefile($id){
@$big=$_POST["big"];
@$small=$_POST["small"];
@$smallest=$_POST["smallest"];
@$title=$_POST["title"];
@$description=$_POST["description"];
@$artist=$_POST["artist"];
$directoryb='../artwork';
$directorys='../artwork/smalls';
$directorys2='../artwork/buttons';
$bigname=basename($big);
$smallname=basename($small);
$smallestname=basename($smallest);
if (!copy($big, "$directoryb/$bigname"))
{ echo "Error uploading the file"; dodelete($id); }
else {
if (!copy($small, "$directorys/$smallname"))
{ echo "Error uploading the file"; dodelete($id); }
else {
if (!copy($smallest, "$directorys2/$smallestname"))
{ echo "Error uploading the file"; dodelete($id); }
else {echo "Your upload worked<br><a href='http://www.artistan.com/artwork.php?id=$id'><font color=black>Go to your artpiece</a></font>";}
}
}
}
function dodelete($id){
$do=mysql_query("DELETE from artwork where artid='$id'");
if (!$do) echo "Sorry, could not delete rows";
}
function writedb(){
global $link_id;
@$big=$_POST["big"];
@$small=$_POST["small"];
@$smallest=$_POST["smallest"];
@$title=$_POST["title"];
@$description=$_POST["description"];
@$artist=$_POST["artist"];
if ((!isset($big)) or ($big=="")) upload_form("No big file to upload");
else {
if ((!isset($title)) or ($title=="")) upload_form("You did not specify a title");
else {
if ((!isset($smallest)) or ($smallest=="")) upload_form("You did not upload a 50 x 50");
else {
if ((!isset($description)) or ($description=="")) upload_form("You did not specify a description");
else {
if ((!isset($small)) or ($small=="")) upload_form("You did not upload a 160 x 120");
else {
if ((!isset($artist)) or ($artist=="")) upload_form("You did give your name");
else {
$doit=mysql_query("INSERT INTO artwork values (null,'$title','$artist','$big','$small','0','0','0', '0', NOW(), '$description','$smallest')");
if (!$doit) echo "Error inserting file into DB";
else {
$id=mysql_insert_id($link_id);
if ($id) {
writefile($id);}
else dodelete($id);
}
}}}}}}
}
@$do=$_POST['do'];
if ((isset($do)) AND ($do=='write')) writedb();
else upload_form(" ");