Jump to content

Recommended Posts

Im trying to test a file upload to a remote server and getting nowhere, I have listed below a simple html form to collect the file for upload. The phpfile file is attached to do the upload. I have heard that the php.ini file needs to have a variable set currently upload_tmp_dir was set to NULL. I have changed this in a local copy of php.ini which I believe needs to be changed I am not familiar with the correct syntax for this but have included by version below also.

 

The file format is root/site/test/  (php & html files)

I want to upload the files to root/site/Uploads

 

(If any other ini variables need to be changed - I have complete control over the website from root downwards)

Please advise correct php.ini file settings

 

 

html file

html>

  <head>

    <title>File Upload Form</title>

  </head>

  <body>

    This form allows you to upload a file to the server.<br>

    <form action="getfile.php" method="post"><br>

      Type (or select) Filename: <input type="file" name="uploadFile">

      <input type="hidden" name="MAX_FILE_SIZE" value="25000" />

      <input type="submit" value="Upload File">

    </form>

  </body>

</html>

 

 

getfile.php

<html>

<head>

<title>Process Uploaded File</title>

</head>

<body>

<?php

 

if ( move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'],

      "site/Uploads/{$_FILES['uploadFile'] ['name']}")  )

      {  print '<p> The file has been successfully uploaded </p>';

      }

else

      {

        switch ($_FILES['uploadFile'] ['error'])

        {  case 1:

                  print '<p> The file is bigger than this PHP installation allows</p>';

                  break;

            case 2:

                  print '<p> The file is bigger than this form allows</p>';

                  break;

            case 3:

                  print '<p> Only part of the file was uploaded</p>';

                  break;

            case 4:

                  print '<p> No file was uploaded</p>';

                  break;

        }

      }

?>

</body>

</html>

 

 

php.ini file

;PHP.ini file

;

;This file contains the changes I have assumed for the php.ini files.

 

;Temporary Upload File Location is been changed from NULL to allow for

;upload capability

 

upload_tmp_dir=/site/Uploads

 

; Maximum allowed size for uploaded files.

upload_max_filesize = 3M

 

;End.

 

Thanks for your help!

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/210406-browse-to-fileimage-upload-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.