Unable to access php.ini

Hey,
I am unable to find the php.ini file on my domain. Also I’m unable to upload file on a directory using a php script.

1 Like

You cannot alter php.ini in this hosting.

About files explain more about it.

4 Likes

So how can I upload file:
I am using the following php script:

<?php
   if(isset($_FILES['image'])){
      $errors= array();
      $file_name = $_FILES['image']['name'];
      $file_size = $_FILES['image']['size'];
      $file_tmp = $_FILES['image']['tmp_name'];
      $file_type = $_FILES['image']['type'];
      $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
      
      $extensions= array("jpeg","jpg","png");
      
      if(in_array($file_ext,$extensions)=== false){
         $errors[]="extension not allowed, please choose a JPEG or PNG file.";
      }
      
      if($file_size > 2097152) {
         $errors[]='File size must be excately 2 MB';
      }
      
      if(empty($errors)==true) {
         move_uploaded_file($file_tmp,"/htdocs/".$file_name);
         echo "Success";
      }else{
         print_r($errors);
      }
   }
?>
<html>
   <body>
      
      <form action = "" method = "POST" enctype = "multipart/form-data">
         <input type = "file" name = "image" />
         <input type = "submit"/>
			
         <ul>
            <li>Sent file: <?php echo $_FILES['image']['name'];  ?>
            <li>File size: <?php echo $_FILES['image']['size'];  ?>
            <li>File type: <?php echo $_FILES['image']['type'] ?>
         </ul>
			
      </form>
      
   </body>
</html>

Any errors?

no

The script says the file uploaded but when i go and check I always find that theres no file uploaded

Maybe because of your CHMOD or permission? Make it wri-writable in public.

Locate the folder where you want to upload the pictures then change the permission to 777.

should be:

move_uploaded_file($file_tmp,__DIR__."/htdocs/".$file_name);

I’ve forgotten php a bit, you might var_dump(__DIR__);
if it has htdocs at end, you should use this:

move_uploaded_file($file_tmp,__DIR__.$file_name);

REMEMBER this is a hosting for hosting websites, not pictures.

3 Likes

Does’nt really works. By the way, thank you so much for giving your time.

???

Hey can I make my own php.ini file and then can I upload it.
Will it work?

Nope that’s not gonna work

2 Likes

Thanks for letting me know about it. But what else can I do

Sorry to tell you but the same thing happens the script says the file has been uploaded but when I go and check it i found nothing.
Here are the screen shots.

Screenshot_13

Have you tried this one? Make it writable in public.

Done. But nothing happens.

Its your php code problem maybe. Try to run the php code with the html first on your pc use xamp for that, and if the problem still occur in your pc, then its your php code problem, not infinityfree server problem.

Hey can you please tell me that
Does Infinity really allow free users to upload file using a php script.
And have you ever tried to upload a file using php script on free account.

Hey there. InfinityFree allows you to upload files as long as:

  1. The file is acceptable. The file is not a prohibited file. The file is safe.
  2. Not exceed to 10MB file upload limit.

For me, I already tried to upload using php. It is working. I even have my own file manager written on PHP.

2 Likes