Having a problem with an upload script.
Posted: Wed May 14, 2003 7:00 pm
Im experiencing a problem with uploading though, it works fine on my PC (win2k, apache, php4 mysql 3.23)but uploaded to a
Linux/apacghe/PHP4/MySQL 3.23 environment results in this:
Warning: Rename failed (Invalid cross-device link) in /var/www/html/employee/admin_picupload.php on line 26
Warning: Cannot add header information - headers already sent by (output started at /var/www/html/employee/admin_picupload.php:26) in /var/www/html/employee/admin_picupload.php on line 34
Form for upload:
Upload php script:
Any ideas on why it would work fine on a Win2k environment but not on apache, and I have all the folders on the servers are chmod to 777 (images folder)
Linux/apacghe/PHP4/MySQL 3.23 environment results in this:
Warning: Rename failed (Invalid cross-device link) in /var/www/html/employee/admin_picupload.php on line 26
Warning: Cannot add header information - headers already sent by (output started at /var/www/html/employee/admin_picupload.php:26) in /var/www/html/employee/admin_picupload.php on line 34
Form for upload:
Code: Select all
<form enctype="multipart/form-data" action="admin_picupload.php" method=POST>
Change Image?
<input name="myfile" type="file">
<input type="hidden" name="emp_id" value="1">
<input type="submit" value="Attach File" name="submit2">
</form>Code: Select all
<?
//-------------------------------
// admin_employeespicupload CustomIncludes begin
include ("./header.php");
include ("./footer.php");
// admin_employeespicupload CustomIncludes end
//-------------------------------
session_start();
//===============================
// admin_employeespicupload PageSecurity begin
check_security(3);
// admin_employeespicupload PageSecurity end
//===============================
function get_param($param_name)
{
global $HTTP_POST_VARS;
global $HTTP_GET_VARS;
$param_value = "";
if(isset($HTTP_POST_VARS[$param_name]))
$param_value = $HTTP_POST_VARS[$param_name];
else if(isset($HTTP_GET_VARS[$param_name]))
$param_value = $HTTP_GET_VARS[$param_name];
return $param_value;
}
//The file to be uploaded
$tmpfile = "images/emps/".$myfile_name;
if (!file_exists($tmpfile)) {
rename($myfile,$tmpfile);
} else {
unlink($tmpfile);
rename($myfile,$tmpfile);
}
//Update the database table for the new record
$uSQL = "update emps set picture='$myfile_name' where emp_id=".get_param("emp_id");
$db->query($uSQL);
// Redirect the user to the admin_employees.php page
header("Location: admin_employees.php");
?>