473,387 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Uploading Files: Definitive answer required. ;-)

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
4 2755
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chamomile | last post by:
can anyone point me to some straightforward information on file uploading without using an html form? That is, direcly from within a php script. if I know the local path etc. to a particular...
1
by: Jim Mitchell | last post by:
I have a rather simple project with several ASPX files. If I make a change to one of the files, can someone tell me the least I need to do to update my project on the server. Right now I am...
18
by: xarax | last post by:
Greetings, What is the general practice, usual and customary way, of including a data file into a source file? I have some large data structures defined as source similar to: ...
3
by: deko | last post by:
Newbie ASP.NET question: Now that I've created an ASP.NET site, how to I get it to my hosting provider? I've developed sites with Dreamweaver MX in the past - with Dreamweaver, it's very...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
5
by: hecuba007 | last post by:
My apologies if this question has been asked before .. I would like to split large files into smaller chunks for uploading to php for re-assembly on the server. Is there a (relatively) simple...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
0
by: PerumalSamy | last post by:
Hi, I am getting following error while uploading my project in web. Description: An error occurred during the processing of a configuration file required to service this request. Please review...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.