my hosting directory permissions is writeable but still i recieved in 0kb files came form my upload page.
momonq1990 0 Newbie Poster
Dani AI
Generated
Brief diagnosis and focused checklist for (and as requested): files arriving as 0 KB are usually not a mysterious PHP bug but one of these categories — upload was rejected/truncated by PHP (config limits or tmp-dir problems), client-side JS prevented a proper multipart POST, or the script wrote an empty file after upload. The posted handler does a straight move but does not print the upload error or debug info, so the next step is to inspect what PHP actually received.
Quick, non-destructive debug to drop into the top of the upload handler (temporary):
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// quick dump to see what arrived
var_export($_FILES);
if (isset($_FILES['uploadedfile'])) {
echo "\nerror=" . $_FILES['uploadedfile']['error'] . "\n";
echo "size=" . $_FILES['uploadedfile']['size'] . "\n";
} Key things to check after that dump:
- Interpret the numeric
errorvalue (0 = OK; 1 = exceeds php.ini upload_max_filesize; 2 = exceeds form MAX_FILE_SIZE; 3 = partial upload; 4 = no file; 6 = missing tmp dir; 7 = failed write; 8 = extension stopped it). - Confirm
sizeis non-zero andtmp_namepoints to an actual file. - Check
php.inisettings:upload_max_filesize,post_max_size,file_uploads, andupload_tmp_dir. Also verify disk space and tmp-dir permissions.
Practical fixes and cautions:
- Use absolute paths (or
__DIR__) for the destination to avoid relative-path confusion with../databank/temp/. Confirm that directory exists and is writable by the web server. - Temporarily remove or bypass the
onclick="req()"JS on the submit button — client-side handlers commonly prevent a proper multipart POST when they replace the submit with an AJAX call that doesn't send FormData. - If the error code shows INI or FORM size limits, increase
upload_max_filesizeandpost_max_size(and restart PHP) or lower the form MAX_FILE_SIZE. - Add explicit checks for the upload
errorand foris_uploaded_file()before moving; log failures to the server error log for later inspection.
Those steps isolate whether the problem is configuration, client-side, or server-side file I/O; once the var_export($_FILES) output is available, the specific cause will be clear.
Recommended Answers
Jump to Post— Szabi Zsoldos 26can you post the code from the upload from your script ?
All 3 Replies
Szabi Zsoldos 26 Learner and helper guy
can you post the code from the upload from your script ?
momonq1990 0 Newbie Poster
<form name="frmUpload" id="frmUpload" enctype="multipart/form-data" action="../dplocation/reupload.php" method="POST" class="appForm">
First Name<span class="s2"></span>Middle Name<span class="s3"></span>Last Name<br>
<input type="text" name="fName" id="fName" class="tb1"><span class="s1"></span><input type="text" name="mName" id="mName" class="tb1"><span class="s1"></span><input type="text" name="lName" id="lName" class="tb1"><br>
Home Address<span class="s4"></span>Contact No.<br>
<input type="text" name="hAdd" id="hAdd" class="tb2"><span class="s1"></span><input type="text" name="cNo" class="tb1" id="cNo"><br>
Email Address<br>
<input type="text" name="eAdd" id="eAdd" class="tb1"><br><br>
<span class="career-title">Educational Background</span><br>
Educational Attainment<span class="s5"></span>Title/Course<span class="s6"></span>Graduate Year<br>
<!--<input type="text" name="eAtt" class="tb1">-->
<select name="eAtt" class="selectjobs">
<option value=""></option>
<option value="Masters">Masters</option>
<option value="College">College</option>
<option value="Vocational">Vocational</option>
<option value="Highschool">Highschool</option>
<option value="Elementary">Elementary</option>
<option value="Others">Others</option>
</select>
<span class="s1"></span><input type="text" name="tandc" id="tandc" class="tb1"><span class="s1"></span><input type="text" name="sy" class="tb1"><br><br>
<span class="career-title">File Application</span><br>
Position<span class="fa1"></span>Resume Databank<br>
<select name="pApp" class="selectjobs" id="selectposition">
<option value=""></option>
<option value="Operaion Staff">Operaion Staff</option>
<option value="Sales Executive">Sales Executive</option>
<option value="Promodizer">Promodizer</option>
<option value="Project Coordinator">Project Coordinator</option>
<option value="Delivery Coordinator">Delivery Coordinator</option>
<option value="Warehouse Helper">Warehouse Helper</option>
<option value="Driver">Driver</option>
</select>
<!--<input type="text" name="pApp" class="tb1"><br>-->
<input type="hidden" name="MAX_FILE_SIZE" value="500000" />
<span class="fa2"></span><input name="uploadedfile" type="file" id="tb3"/>
<div id="reqnote"></div><br><br>
<input type="submit" value="Send Application" class="jobSend" onclick="req()">
</form>
momonq1990 0 Newbie Poster
$target_path = "../databank/temp/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$filename = $_FILES['uploadedfile']['name'];
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.