Jump to content

Upload success at localhost but not in server.please help.....


new_php85

Recommended Posts

Hi Guys

 

I don't why it happen. probably i missed out something. :(

 

Here is my code.

 

<?php
if($_REQUEST["xtvt"]=="addEdit")
{
$sql02="INSERT INTO attachment (remarks, attached_by, attached_date)
	      VALUES('".$_REQUEST["remarks"]."', '".$_SESSION["SESSION_ID"]."', now())";
$res02=mysql_query($sql02);

//--------- attach file ----------------------------
$name = $_FILES["file"]["name"]; 
if ($name != "")
{
	$selectDB="SELECT max(id) AS id FROM attachment";
	$qryDB= @$res1=mysql_query($selectDB);	
	$fetchDB=mysql_fetch_array($qryDB);

	$maxid=$fetchDB[0];
	$result=move_uploaded_file($_FILES["file"]["tmp_name"], "upload//" . $_FILES["file"]["name"]);
	if (!$result) {
		echo "Error uploading file";
	}
	$update_faultLog = "UPDATE attachment SET attachment='$name' WHERE id='$maxid'";
	$res1=mysql_query($update_faultLog);			
}	
}
?>

<table width="625" border="0">
  <tr>
    <td width="78">Select File <span class="style1">*</span></td>
    <td width="5">:</td>
    <td width="539"><input type="file" name="file" id="file"/></td>
  </tr>
  <tr>
    <td>Remarks <span class="style1">*</span></td>
    <td>:</td>
    <td><pre><textarea name="remarks" id="remarks" cols="45" rows="3"></textarea></pre></td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td><input type="reset" id="bttnReset" name="bttnReset" value="Reset" onclick="Reset()"/>
	<input type="button" id="bttnAdd" name="bttnAdd" value="Add" onclick="addEdit()"/></td>
  </tr>
</table>

 

Its work at localhost but not when i put at server...

 

please help me... :(

 

Thank You

Link to comment
Share on other sites

What exactly happens when you try this? An error? blank page? do you have error reporting set up? put the following code at the top of your page to turn it on

ini_set('display_errors',1);
error_reporting(E_ALL);

 

report back with more information please. Posting some code, and saying "It doesn't work, HALP" makes it difficult for us to help you

Link to comment
Share on other sites

Here is my form

 

<form name="form1" id="form1" action="" method="post" enctype="multipart/form-data">
<table width="625" border="0">
  <tr>
    <td width="78">Select File <span class="style1">*</span></td>
    <td width="5">:</td>
    <td width="539"><input type="file" name="file" id="file"/></td>
  </tr>
  <tr>
    <td>Remarks <span class="style1">*</span></td>
    <td>:</td>
    <td><pre><textarea name="remarks" id="remarks" cols="45" rows="3"></textarea></pre></td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td><input type="reset" id="bttnReset" name="bttnReset" value="Reset" onclick="Reset()"/>
	<input type="button" id="bttnAdd" name="bttnAdd" value="Add" onclick="addEdit()"/></td>
  </tr>
</table>
</form>

Link to comment
Share on other sites

Nothing in your form is named  'xtvt', nor valued as 'addEdit'.

if($_REQUEST["xtvt"]=="addEdit")

 

Its from JS function

 

here the code

<script language="javascript">
function addEdit()
{
var file=document.form1.file.value;
var remarks=document.form1.remarks.value;
var do_done="";

if(file=="" || remarks=="")
{
	alert("Please fill in all field remarked (*).");
	do_done='N';
}

else
{
	var x=document.getElementById("form1");
	x.action="attachment.php?xtvt=addEdit";
	x.target="_self";
	x.submit();
}
}
</script>

 

All sql are works except this part

 

$result=move_uploaded_file($_FILES["file"]["tmp_name"], "upload//" . $_FILES["file"]["name"]);
if (!$result) 
{
    echo "Error uploading file";
}

Link to comment
Share on other sites

is there a reason you are using 2 forward slashes in the filepath here:

$result=move_uploaded_file($_FILES["file"]["tmp_name"], "upload//" . $_FILES["file"]["name"]);

 

Not sure if this is giving you an error, but this may be leading to unexpected results

Link to comment
Share on other sites

here is my path for upload folder

 

var/www/crm_VT/upload

 

that why i put double slashes.

$result=move_uploaded_file($_FILES["file"]["tmp_name"], "upload//" . $_FILES["file"]["name"]);

 

however i,  change also my code into these

$result=move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);

 

and

 

$result=move_uploaded_file($_FILES["file"]["tmp_name"], "upload" . $_FILES["file"]["name"]);

 

and

 

$result=move_uploaded_file($_FILES["file"]["tmp_name"], $_FILES["file"]["name"]);

 

all not works. but success at localhost

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.