mike wrote:
> Jerry Stuckle wrote:
>> mike wrote:
>>
>>> Jerry Stuckle wrote:
>>>
>>>> mike wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> I am new and trying to learn php. I am trying to use some of the
>>>>> scripts in the php manual (http://www.php.net/manual/en/) to upload
>>>>> a file. I can not seem to get the file to upload. Actually I am
>>>>> "uploading" to the same windows XP computer, trying to move the
>>>>> file from one directory to another. It appears that the file is
>>>>> suppose to be passed to a temporary file in a temporary directory.
>>>>> I think this is where I am having trouble. The form script seems to
>>>>> get the file correctly. It calls and posts to the file processing
>>>>> script correctly. But the file
>>>>> processing script fails. I get error 6 which is "Missing a
>>>>> temporary folder." (see below for complete scripts and outputs)
>>>>>
>>>>> If I do a phpinfo() call I see that upload_tmp_dir is not set
>>>>> if I do $a=ini_get('upload_tmp_dir'); and echo $a I get NULL.
>>>>>
>>>>> The manual says that 'upload_tmp_dir' is set in php.ini. I found
>>>>> php.ini in the Program Files/php/ directory. I find the variable set
>>>>> in 2 places in that file:
>>>>>
>>>>> ******
>>>>> .
>>>>> .
>>>>> .
>>>>> ; Whether to allow HTTP file uploads.
>>>>> file_uploads = On
>>>>>
>>>>> ; Temporary directory for HTTP uploaded files (will use system
>>>>> default ;if not
>>>>> ; specified).
>>>>> ;upload_tmp_dir =
>>>>> .
>>>>> .
>>>>> .
>>>>> ; Default timeout for socket based streams (seconds)
>>>>> default_socket_timeout = 60
>>>>> upload_tmp_dir="C:\DOCUME~1\MIA-KI~1\LOCALS~1\Temp\php\upload"
>>>>> session.save_path="C:\DOCUME~1\MIA-KI~1\LOCALS~1\Temp\php\session"
>>>>> .
>>>>> .
>>>>> .
>>>>> *********
>>>>> The directory set in the 2nd instance:
>>>>>
>>>>> upload_tmp_dir="C:\DOCUME~1\MIA-KI~1\LOCALS~1\Temp\php\upload"
>>>>>
>>>>> exists on my pc, however, phpinfo() says 'upload_tmp_dir' is not set.
>>>>>
>>>>> If I uncomment the 1st instance and set it:
>>>>>
>>>>> upload_tmp_dir ="C:\tempphp" (a directory which I have created)
>>>>>
>>>>> phpinfo() reports 'upload_tmp_dir' is not set.
>>>>>
>>>>> I have tried puting the php.ini file in my wwwroot directory and in
>>>>> the working directory containing the scripts (I think this is where
>>>>> it should be) and still phpinfo() reports 'upload_tmp_dir' is not set.
>>>>>
>>>>> I have also tried ini_set('upload_tmp_dir', 'C:\tempphp');
>>>>> that also does not work.
>>>>>
>>>>> *********************************************
>>>>> Q1: How do I set the temporary upload file 'upload_tmp_dir' in
>>>>> windows XP.
>>>>>
>>>>> Q2: Once I have set 'upload_tmp_dir' how do I know the temproary
>>>>> file name 'tmp_name' that php uses to hold that file before it gets
>>>>> moved using:
>>>>>
>>>>> move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)
>>>>>
>>>>> Thank You
>>>>> Mike
>>>>>
>>>>>
>>>>>
>>>>> ********************************************
>>>>> I use the following to generate a form to get the file name:
>>>>> *****
>>>>>
>>>>> <!-- The data encoding type, enctype, MUST be specified as below -->
>>>>> <form enctype="multipart/form-data"
>>>>> action="http://localhost/php/upload.php" method="POST">
>>>>> <!-- MAX_FILE_SIZE must precede the file input field -->
>>>>> <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
>>>>> <!-- Name of input element determines name in $_FILES array -->
>>>>> Send this file: <input name="userfile" type="file" />
>>>>> <input type="submit" value="Send File" />
>>>>> </form>
>>>>> <h1> hello world</h1>
>>>>> </body>
>>>>> </html>
>>>>>
>>>>> ******************************************
>>>>> Then I use the following php script
>>>>> (http://localhost/php/upload.php) to do the moving:
>>>>> ******
>>>>>
>>>>> <html>
>>>>> <body>
>>>>> <?php
>>>>> // In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be
>>>>> used instead
>>>>> // of $_FILES.
>>>>>
>>>>> $uploaddir = './upload/';
>>>>> $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
>>>>>
>>>>> echo '<pre>';
>>>>> if (move_uploaded_file($_FILES['userfile']['tmp_name'],
>>>>> $uploadfile)) {
>>>>> echo "File is valid, and was successfully uploaded.\n";
>>>>> } else {
>>>>> echo "Possible file upload problem\n";
>>>>> }
>>>>>
>>>>> echo 'Here is some more debugging info:';
>>>>> print_r($_FILES);
>>>>>
>>>>> print "</pre>";
>>>>>
>>>>> ?>
>>>>> </body>
>>>>> </html>
>>>>> ***********************************
>>>>>
>>>>> I get the following output:
>>>>>
>>>>> *******
>>>>>
>>>>> Possible file upload problem
>>>>> Here is some more debugging info:Array
>>>>> (
>>>>> [userfile] => Array
>>>>> (
>>>>> [name] => usage_rights.txt
>>>>> [type] =>
>>>>> [tmp_name] =>
>>>>> [error] => 6
>>>>> [size] => 0
>>>>> )
>>>>>
>>>>> )
>>>>>
>>>>
>>>> The first question is - which configuration file does phpino() say
>>>> it's using?
>>>>
>>>
>>> Hi Jerry,
>>>
>>> Configuration File (php.ini) Path C:\WINDOWS
>>>
>>> however when I look in the windows directory there is no php.ini file.
>>>
>>> Mike
>>>
>>
>> OK, so it's using a default file. The easiest way right now to change
>> that is to put your php.ini file in c:/windows.
>>
> OK I placed the php.ini file in the c:/windows directory but phpino()
> still reports 'upload_tmp_dir' as unset. Do I need to stop and restart
> the IIS web server.
>
> Thanks
> mike
>
Of course. Why didn't you just try it instead of asking here?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================