By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,483 Members | 3,312 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,483 IT Pros & Developers. It's quick & easy.

Uploading Files: Definitive answer required. ;-)

P: n/a
Hi there.

I've spent the weekend getting ever more frustrated, trying to get an
upload file function working on a website.

The site is hosted by a company called oneandone. They're using PHP 4.2.
3, not in safe mode. I think that the basic problem is the set-up for
the temp folder, but I don't have access to the .ini settings.

I'm pretty sure it's possible, because I've got MyPHPAdmin running, and
it's happily accepting uploaded files (although I can't make head nor
tail of their code).

I've read through the manuals online (most of which assume 'it just
sorta works' or that you have access to the .ini files), and I've tried
setting the values for upload_tmp_dir using ini_set() but I just can't
get it to work.

Here's the code I'm stuck with at the moment...

file 1: upload.php

****

<?php
$root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
ini_set('upload_tmp_
dir', $root.'tmp');
?> <html>
<head>
<title>Administration - file
upload</title>
</head>
<body>
<h1>Upload new files</h1>
<form
enctype="multipart/form-data" action="upload2.php" method="post">

<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
Upload
this file: <input name="userfile" type="file">
<input type="submit"
value="Send File">
</form>
</body>
</html>

***

file 2: upload2.php

***
<?php
$root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
ini_set('upload_tmp_
dir', $root.'tmp');
?> <html>
<head>
<title>Uploading...</title>
</
head>
<body>
<h1>Uploading file...</h1>
<?php
echo 'Document
root is '.$root."<br />\n";
echo 'Upload directory: '.ini_get('upload_
tmp_dir')."<br />\n";
echo 'Upload directory: '.get_cfg_var('upload_tmp_dir')."\n";
?>
</body>
</html>

***

(I realise that this doesn't actually do any uploading, but I've rolled
it back as far as I can, as a follower of a walk then run school of
philosophy, just to get it to tell me where it might deign to upload
stuff, were it to work ;-) )

When I execute these two pages, the second page just coughs up a blank
Upload directory, as if it hasn't been set. Can somebody please point
me in the right direction?!?!? My desk is starting to get a forehead
shapped dent in it... I just want to upload some plain text files and a
few 4k jpgs for goodness sake!

Aaarrrgh.
Thanks.

dd
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Wil
I've been looking at stuff all weekend on googlegroups and I've come
to the conclusion that on shared servers you can't alter
upload_tmp_dir using ini_set().
Jul 17 '05 #2

P: n/a
Wil wrote:
I've been looking at stuff all weekend on googlegroups and I've come
to the conclusion that on shared servers you can't alter
upload_tmp_dir using ini_set().


That's the same conclusion you'd reach by reading ini_set on the manual
:)

http://www.php.net/ini_set
The info for "upload_tmp_dir" on the "Changeable" column has
"PHP_INI_SYSTEM" wich is specified as "Entry can be set in php.ini or
httpd.conf"
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #3

P: n/a
jn
"Pedro Graca" <he****@hotpop.com> wrote in message
news:c1*************@ID-203069.news.uni-berlin.de...
Wil wrote:
I've been looking at stuff all weekend on googlegroups and I've come
to the conclusion that on shared servers you can't alter
upload_tmp_dir using ini_set().


That's the same conclusion you'd reach by reading ini_set on the manual
:)

http://www.php.net/ini_set
The info for "upload_tmp_dir" on the "Changeable" column has
"PHP_INI_SYSTEM" wich is specified as "Entry can be set in php.ini or
httpd.conf"
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--


Did you try putting something like this in an .htaccess file?

php_value upload_tmp_dir /whatever/dir/you/want
Jul 17 '05 #4

P: n/a
On Mon, 02 Feb 2004 14:17:56 +0000, dickiedyce wrote:
Hi there.

I've spent the weekend getting ever more frustrated, trying to get an
upload file function working on a website.

The site is hosted by a company called oneandone.

Oops! ;)

They're using PHP 4.2.
3, not in safe mode. I think that the basic problem is the set-up for the
temp folder, but I don't have access to the .ini settings.

I personally think the issue is elsewhere...

I'm pretty sure it's possible, because I've got MyPHPAdmin running, and
it's happily accepting uploaded files (although I can't make head nor tail
of their code).

I'd say it's uploading fine (assuming your account isn't more restricted
than wherever phpMA runs).

I've read through the manuals online (most of which assume 'it just sorta
works' or that you have access to the .ini files), and I've tried setting
the values for upload_tmp_dir using ini_set() but I just can't get it to
work.

I have to ask.. why?

Why are you trying to change the temp upload dir? What's wrong with the
current one?

Here's the code I'm stuck with at the moment...

[ snip code with no code to process uploaded file ]

(I realise that this doesn't actually do any uploading, but I've rolled it
back as far as I can, as a follower of a walk then run school of
philosophy, just to get it to tell me where it might deign to upload
stuff, were it to work ;-) )

When I execute these two pages, the second page just coughs up a blank
Upload directory, as if it hasn't been set. Can somebody please point me
in the right direction?!?!? My desk is starting to get a forehead shapped
dent in it... I just want to upload some plain text files and a few 4k
jpgs for goodness sake!

Aaarrrgh.

Did you move the uploaded file to your specified dir before the end of the
script finished executing? You've shown no code that would deal with this.

When a file is uploaded, it's stored in the $TEMP dir as something like:
php87Dkdfs9
You then use something like 'move_upload_file()' to put this into
$YOUR_CHOSEN_PATH as $YOUR_DEFINED_FILENAME.

If you already have this code present but didn't post it here, if you
could post the section maybe it can be analysed better (I'm not saying
this _is_ the problem, but without seeing anymore of your code, it's my
first suspect).

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.