Yeni bir dosya yükleme yöntemi çalışıyor

1 Cevap php

bu yüzden web sunucusu alanı yerine mysql alan ama ben aşağıdaki hatayı alıyorum şey yüklemeye çalıştığınızda her zaman üzerine dosya yüklemek için karar verdik:

    Warning: move_uploaded_file() [function.move-uploaded-file]: Filename cannot be empty in /home/speedycm/public_html/manageclient.php on line 240

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpq7cUA4' to '' in /home/speedycm/public_html/manageclient.php on line 240
Error uploading file

Bu kullanarak kod im:

 <?php
                 if (array_key_exists('uploadfile',$_POST)) {

$uploadDir = '/upload';

$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$filePath = $uploadDir . $fileName;

// get the file extension first
$ext = substr(strrchr($fileName, "."), 1); 

// make the random file name
$randName = md5(rand() * time());

// and now we have the unique file name for the upload file
$filePath = $uploadDir . $randName . '.' . $ext;

$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}

if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$content = addslashes($filePath);
}

mysql_query("INSERT INTO tbl_accidentfiles (`client_id`,`name`,`type`,`size`,`path`)
VALUES ('$client_id', '$fileName', '$fileType', '$fileSize','$filePath')");

echo '<b>File Upload</b><p>Thank you. The file has been successfully uploaded.

<p><img src="resources/spacer.gif" alt="" width="300px" height="5px" /><p><o>

<i><u>Name:</u>&nbsp;' . $fileName . '<p><i><u>Size:</u>&nbsp;' . $fileSize . 'k' . '<p><u>Type:</u>&nbsp;' . $fileType . '</i><i><u>Path:</u>&nbsp;' . $filePath. '<p><p><p><img src="resources/spacer.gif" alt="" width="300px" height="5px" />';

ben yanlış yapıyorum ne olarak herhangi bir fikir?

1 Cevap

Uyarı: move_uploaded_file () [function.move-tarih-file]: Dosya on line in / home / speedycm / public_html / manageclient.php boş olamaz 240

Bu ne olursa olsun $_FILES['userfile']['tmp_name'] aslında boştur, ya da yok yoluyla geliyor demektir. Run print_r veya var_dump üzerine $_FILES aslında orada neler olduğunu görmek için. Şansını bir yerde yazım hatası var vardır.