Page 1 of 1

Uploading a file to my server

Posted: Wed Jan 15, 2003 7:49 pm
by jasonfb
PHP / APACHE GURU NEEDED


I am trying to configure a PHP script to allow remote uploads a file to my server via a web page using a little "Browse" button to let someone select a file to upload and a "Send File" button which submits, using an HTML <form...> element, a file to the server to be saved on the server.

My server operates on a for-better-or-worse static Cable Modem connection, which I have had consistent ability to dynamically route using DynDNS. Getting to the server using my dyndns forwarder has never been a problem.

My OS is Mac OS X distribution 10.2.3, which is running on a BIND distribution, I don't know which one.

I have installed and configured PHP 4.1.2. I verified that PHP was running by using the

<?php phpinfo() ?>

instruction, and can see the PHP global variables from this page. You can can it at:

http://jfb.homeip.net/~melon/test.php


What I am trying to do is write a basic script to upload a file to my server. To do this I used a tag as follows

<form ACTION="http://datatravels.serveftp.net/~upload/test2.php" ENCTYPE="multipart/form-data" method="POST" Name="">
<input type="hidden" name="MAX_FILE_SIZE" value="1000">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>



The web page can be found at

http://jfb.homeip.net/~upload/upload.html


The PHP script, which I wrote with the help of this online manual:

http://www.php.net/manual/en/features.file-upload.php


The PHP script is stored at

http://jfb.homeip.net/~upload/test2.php

You can't see it, of course, because calling it will cause the script to run and return (empty) HTML to the document.

It is a script that just calls the 5 associates functions file uploads that I referenced on phpn.net, as listed below:


$_FILES['userfile']['name']

The original name of the file on the client machine.
$_FILES['userfile']['type']

The mime type of the file, if the browser provided this information. An example would be "image/gif".
$_FILES['userfile']['size']

The size, in bytes, of the uploaded file.
$_FILES['userfile']['tmp_name']

The temporary filename of the file in which the uploaded file was stored on the server.
$_FILES['userfile']['error']



Here's what the symptom is:

When I try to upload a file, the server's response is to supply the accurate 'name', and 'type'. Unfortuntely, it doesn't seem to me that anything is uploaded because it always returns 0 as the size and as far as I can tell there aren't any new files on the server. A 'tmp_name", which is supposed to be the file name on the server, shows 'none' and the file upload shows error.

I believe the error might be in that I haven't set the upload_tmp_dir variable correctly. You can see the value of the variable at
http://jfb.homeip.net/~melon/test.php

on this page which shows all the PHP global variables it is set to "no value"

I am looking for anyone to help me solve this problem immediately, compensation negotiable. Any assistance of any kind would be greatly appreciated. I can give you administrative access to the server to let you make all the edits needed to get the file upload feature to work. From there on out I assume we will be able to work over the telephone as necessary and the job can be completed via telecommute.

I am available by telephone at 917-622-3021 or e-mail at tech@nycboy.com

Thank you for taking the time to look into this.

-Jason Boldt

Posted: Thu Jan 16, 2003 2:22 am
by twigletmac
Hi I moved this to the PHP forum because you may get a better response there.

*bump*

Mac

Posted: Thu Jan 16, 2003 2:31 am
by volka
if you want to know where php.ini is located at MacOS X there is a thread How to edit PHP settings in OSX as there's no php.ini file? in the PHPMac.com forum.