new_php85 Posted June 1, 2011 Share Posted June 1, 2011 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 https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/ Share on other sites More sharing options...
revraz Posted June 1, 2011 Share Posted June 1, 2011 Need to explain what doesn't work better. Errors? What isn't working? What is it doing? What isn't it doing? Link to comment https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/#findComment-1223391 Share on other sites More sharing options...
new_php85 Posted June 1, 2011 Author Share Posted June 1, 2011 Need to explain what doesn't work better. Errors? What isn't working? What is it doing? What isn't it doing? Sorry, missed out to explain. there are no file uploaded into folder upload. Link to comment https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/#findComment-1223394 Share on other sites More sharing options...
revraz Posted June 1, 2011 Share Posted June 1, 2011 Do you have access to the server log? Link to comment https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/#findComment-1223395 Share on other sites More sharing options...
new_php85 Posted June 2, 2011 Author Share Posted June 2, 2011 What do you means by that? Actually I don't know how to check either that folder give me full access or not because it located at linux server. i don't have any experience on that. please advice. and Link to comment https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/#findComment-1223823 Share on other sites More sharing options...
mikesta707 Posted June 2, 2011 Share Posted June 2, 2011 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 https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/#findComment-1223836 Share on other sites More sharing options...
jcbones Posted June 2, 2011 Share Posted June 2, 2011 Where is your form? Link to comment https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/#findComment-1223839 Share on other sites More sharing options...
new_php85 Posted June 2, 2011 Author Share Posted June 2, 2011 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 https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/#findComment-1223874 Share on other sites More sharing options...
jcbones Posted June 2, 2011 Share Posted June 2, 2011 Nothing in your form is named 'xtvt', nor valued as 'addEdit'. if($_REQUEST["xtvt"]=="addEdit") Link to comment https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/#findComment-1223876 Share on other sites More sharing options...
new_php85 Posted June 2, 2011 Author Share Posted June 2, 2011 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 https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/#findComment-1223885 Share on other sites More sharing options...
mikesta707 Posted June 2, 2011 Share Posted June 2, 2011 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 https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/#findComment-1223890 Share on other sites More sharing options...
new_php85 Posted June 2, 2011 Author Share Posted June 2, 2011 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 https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/#findComment-1223899 Share on other sites More sharing options...
mikesta707 Posted June 2, 2011 Share Posted June 2, 2011 hmm well are you sure the file you are trying to upload is making it to the tmp directory? try adding if (!is_uploaded_file($_FILES['file']['tmp_name'])){ echo "File failed to upload"; } before your move_uploaded_file() line Link to comment https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/#findComment-1223904 Share on other sites More sharing options...
new_php85 Posted June 2, 2011 Author Share Posted June 2, 2011 ya...not success it came out with this "File failed to upload". why ya?? Link to comment https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/#findComment-1223916 Share on other sites More sharing options...
Pikachu2000 Posted June 2, 2011 Share Posted June 2, 2011 See if there's an error code present in the array, then go HERE to decipher it. echo '<pre>'; print_r($_FILES); echo '</pre>'; Link to comment https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/#findComment-1223924 Share on other sites More sharing options...
new_php85 Posted June 2, 2011 Author Share Posted June 2, 2011 HI guys i got. its because of permission. i just right click the folder at ftp and give full permission on that.. that to all of u..really appreciate Link to comment https://forums.phpfreaks.com/topic/238070-upload-success-at-localhost-but-not-in-serverplease-help/#findComment-1223942 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.