Move_uploaded_files xls?

Username (e.g. epiz_XXX) or Website URL epiz_26912571

Error Message

I am not getting an error message in fact is says uploaded successfully

Other Information

I am trying to upload xls files via php

$target_dir = _DIR_.“/upload/”;
$target_file = $target_dir.basename($_FILES[“userfile”][“name”]);

When I var dump $_FILES it works and shows me the temp location.
When I add this :
$error = $FILES[“userfile”][“error”];
echo “Error:”.$error.“\n”;
I get zero or no errors.
But when I check the file directory “upload” the test file is not there?
Maybe xls files are not allowed? I
added "__DIR_
." after it did not work with just upload?
Thanks

The InfinityFree web servers have size limits for all files. If the file size exceeds the limit, the file is automatically deleted.

The size limits are:

  • HTML and PHP files are limited 1 MB.
  • .htaccess files are limited to 10 kB.
  • All other files are limited to 10 MB.
3 Likes

Could you please share the full code snippet?

<?php
$target_dir = __DIR__."/upload/";
$target_file = $target_dir.basename($_FILES["userfile"]["name"]);
echo "var dump \$_Files: \n";
// returns the global array for FILES just for debugging. All looks good
var_dump($_FILES);
echo "vardump \$_Post: \n";
var_dump($_POST);
// return the global array for POST for debugging all looks fine.
echo $target_file;
//returns full target path for debugging fine
move_uploaded_file(($_FILES["userfile"]["name"]), $target_file);
$error = array();
$error = $_FILES["userfile"]["error"];
//returns "0" error for debugging. Looks fine
echo "Error:".$error."\n"; 
?>

Note that sometimes it takes a few minutes for files uploaded in that way to show up when connected to the FTP server. I can’t see anything wrong with your code, but maybe try putting your move_uploaded_file into an if statement to see if thats causing an issue.

5 Likes

I moved the command to an if statement. Not it says “not uploaded” which is the echo statement I put in the else brackets.

I figured it out.
move_uploaded_file(($_FILES[“userfile”][“tmp_name”]), $target_file);

2 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.