我正在尝试将一个文件上传到本地主机服务器,但它不起作用。我正在尝试使用 chmod 授予文件所在文件夹的权限,但我不明白。该表单在一个名为 index.php 的文件中动态打印,当单击提交时,数据将被接收到名为 recExpediente.php 的同一 php 文件中。
PHP
<?
ini_set('error_reporting', E_ALL);
require('conectaDemo.php');
if (is_uploaded_file($_FILES['Foto']['tmp_name'])) {
$cSQL="SELECT NIF FROM CLIENTES WHERE ID_CLIENTE=?";
$stmt=$oConni->prepare($cSQL) or die($oConni->error);
$stmt->bind_param('i',$_POST['selDesc2']);
$stmt->execute();
$stmt->bind_result($DNI);
if ($stmt->fetch()) {
chmod('/var/www/pracRemesas/'.$DNI.'/', 0777);
echo '/var/www/pracRemesas/'.$DNI.'/';
$uploaddir='/var/www/pracRemesas/'.$DNI.'/';
}
$stmt->close();
$uploadfile = $uploaddir . basename($_FILES['Foto']['name']);
move_uploaded_file($_FILES['Foto']['tmp_name'], $uploadfile);
$cFoto=basename($_FILES['Foto']['name']);
$xSQL = "INSERT INTO EXPEDIENTES (ID_CLIENTE, DOCUMENTO,
OBSERVACIONES) VALUES(?,?,?)";
$stmt = $oConni->prepare($xSQL);
$stmt->bind_param('iss', $_POST['selDesc2'], $cFoto, $_POST['observ']);
$stmt->execute();
$stmt->close();
}
if (isset($_POST['newid'])) {
$cSQL="SELECT ID_CLIENTE, NOMBRE FROM CLIENTES";
$stmt=$oConni->prepare($cSQL) or die($oConni->error);
$stmt->execute();
$stmt->bind_result($ID_CLIENTE, $NOMBRE);
echo'<form name="nuevoExp" id="frmLogin" action="recExpediente.php" method="POST" enctype="multipart/form-data">';
echo'<select id="selDesc2" name="selDesc2">';
echo'<option value=-1>Seleccione cliente</option>';
while ($stmt->fetch()) {
echo'<option value="'.$ID_CLIENTE.'">'.$NOMBRE.'</option>';
}
$stmt->close();
echo'</select><br>';
echo'<input type="file" name="Foto" id="Foto"><br>';
echo'Observaciones<input type="text" name="observ" id="observ"><br>';
echo'<input type="submit" name="butEnv" id="butEnv" value="Enviar"/>';
echo'</form>';
}?>