# Image Or File Upload Works On Localhost But Not On Server

**URL:** <https://forum.kirupa.com/t/image-or-file-upload-works-on-localhost-but-not-on-server/211925>\
**Category:** programming\
**Created:** [January 6, 2007, 2:24pm UTC](https://forum.kirupa.com/t/image-or-file-upload-works-on-localhost-but-not-on-server/211925 "2007-01-06T14:24:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![taurus5\_6](https://avatars.discourse-cdn.com/v4/letter/t/9d8465/32.png) [@taurus5\_6](https://forum.kirupa.com/u/taurus5_6)\
**Post date:** [January 6, 2007, 2:24pm UTC](https://forum.kirupa.com/t/image-or-file-upload-works-on-localhost-but-not-on-server/211925/1 "2007-01-06T14:24:32Z")

</div>

I have an upload image page in my site and it works pretty well in my localhost.

However, when i uploaded it in my server, the error message I have in my php is displayed. What seems to be the problem?

> 

\<?php $saveto = $\_POST[“saveto”];//get action variable from browsefile ?\>

\<?  
if(file\_exists(“…/images/$saveto/” + $\_FILES[‘txt\_file’][‘name’])) {  
echo("\<center\>  
\<font class="blackHeader"\>\<b\>File already exists! Please rename the file.\</b\>\</font\> \<br /\>\<br /\>  
\<a href="javascript: window.close()" class="black"\>\<u\>close this window\</u\>\</a\>  
\</center\>  
");  
}  
else {  
if(is\_file($txt\_file)) {

$target\_path = “…/images/$saveto/”;  
//Result is “uploads/filename.extension” \*/  
$target\_path = $target\_path . basename( $\_FILES[‘txt\_file’][‘name’]);  
$\_FILES[‘txt\_file’][‘tmp\_name’];

if(move\_uploaded\_file($\_FILES[‘txt\_file’][‘tmp\_name’], $target\_path)) {

echo(“\<script language="javascript" type="text/JavaScript"\>  
\<!–  
window.opener.document.frm.$frm.value="$txt\_file\_name";  
window.opener.focus();  
window.close();  
//–\>  
\</script\>”);  
}  
else {  
echo(“\<div align="center"\>\<font class="blackHeader"\>Could not copy file. Your file must be corrupted!\</font\>\</div\>”);  
}  
}  
}  
?\>

What seems to be the problem? Im so confused… thanks.
