uploaded file has zero bytes
Moderator: General Moderators
uploaded file has zero bytes
Hi,
I am uploading multiple files.
The files get uploaded without any error but the last file always shows as zero byte size.
This problem is driving me nuts.
I would appreciate any pointers to solve the problem.
Thanks
-Nayeem
I am uploading multiple files.
The files get uploaded without any error but the last file always shows as zero byte size.
This problem is driving me nuts.
I would appreciate any pointers to solve the problem.
Thanks
-Nayeem
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
Why dont you post your print_r($_FILES) result ?
Wild Guess : You're interpreting the array as $_FILES['userfile'][$i]['name'] instead of $_FILES['userfile']['name'][$i]
Wild Guess : You're interpreting the array as $_FILES['userfile'][$i]['name'] instead of $_FILES['userfile']['name'][$i]
Code: Select all
$n = count($_FILES['userfile']['name']);
echo $_FILES['userfile'][$n-1]['size']."\n<br>";
echo $_FILES['userfile']['size'][$n-1]."\n<br>";Here is part of code which does the uploading part based on the number of files specified by the user to upload in the form
This just a part of code which does the uploading part.
After the uploading is complete, when I check the files size on the file server I see that the last file that has been uploaded has a zero size.
Thanks for looking into it.
-Nayeem
Code: Select all
$uploadNeed = $_POST['uploadNeed'];
//start for loop
if(isset($_SESSION))
{
// Run through all the uploaded files
for($x=0; $x<$uploadNeed;$x++)
{
$file_name = $_FILES['uploadFile'.$x]['name'];
// strip file_name of slashes
$file_name = stripslashes($file_name);
$file_name = str_replace("'","",$file_name);
if(!ssh2_scp_send ($ss_connect,$_FILES['uploadFile'.$x]['tmp_name'],targetfile,0744))
{
echo "Problem: Could not move $file_name into directory";
display_user_menu();
do_html_footer();
exit;
}
}After the uploading is complete, when I check the files size on the file server I see that the last file that has been uploaded has a zero size.
Thanks for looking into it.
-Nayeem
Odd that you are doing
It should be something like
Code: Select all
$file_name = $_FILES['uploadFile'.$x]['name'];Code: Select all
$file_name = $_FILES['uploadFile']['name'][$x];That didn't solve it. That is just a workaround. You shouldn't have to check that.
Your input fields should be like this:
That way you eliminate numbering in your processing script, and you can easily loop through the entire set of uploaded files, no matter if there are 100 or 1.
Your input fields should be like this:
Code: Select all
<input type="file" name="fileUpload[]" size="20" />
<input type="file" name="fileUpload[]" size="20" />Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.