Reply
how to adress server variables
Old 07-04-2004, 07:19 AM how to adress server variables
Junior Talker

Posts: 2
hi folks,

i have an upload directory outside the folder structure where my domain is pointed.

/home/www ->domain
/home/uploads

my provider tells me to adress the files in uploads with the server variable upload_tmp_dir.

But: How does that work? How can I access the files in the uploads folder?

thanks for your feedback

marcell
trainspotter is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-04-2004, 01:00 PM
celticbrue's Avatar
Extreme Talker

Posts: 175
Location: Wiltshire, England
Hi Marcell,

The first thing I'd like to do is point out that I am not an expert on servers so what follows is a little bit of stab in the dark. I just hope it is at least on the right lines.

The question you pose actually has some pretty blurred boundaries in that it encompasses server/directory set up, ftp and php coding.

I am assuming that like most of us, you are using a shared server to host your site. As such your webspace is normally arranged with the following structure: -

/home/domain_username/public_html/

When using ftp to upload files to your webspace, they are placed in the public_html folder, so for instance, www.yourdomain.com/index.html translates to /home/domain_username/public_html/index.html on the server.

The domain_username part of this structure is usually the same as your ftp username, which should have been provided to you by your hosting company.

When you upload a file to the server via a web page instead of ftp, the file is placed into temporary directory that is created "on the fly" by the server. In order for your web pages to access this file, it needs to be moved to a location within your web space (public_html/uploads/ for instance).

At this point, I think it would be best to do a "walk through" with you.

1. Open up your ftp programme and connect as if you were uploading web page.
2. Create a new folder and call it uploads.
3. Set the permissions on this new folder to RWX-RWX-RWX (CHMOD 777)

Next we'll do the form and the code that handles the upload

PHP Code:
<html>
<head>
<title>Upload File</title>
</head>
<body>

<?php

//Don't forget to change domain_username to whatever your ftp username is

if($submit) {

if (
$file1_name != "") {

move_uploaded_file("$file1" "/home/domain_username/public_html/uploads/$file1_name")
or die(
"<br />Couldn't Upload Your File.");

}

print(
"Upload Completed"<br />);

}

?>

<form action="<?php $PHP_SELF ?>" method="post" ENCTYPE="multipart/form-data">

File for Upload: <input type="file" name="file1" value="" />
<br />
<input class=box type="submit" name="submit" value="Upload File" />
</form>

</body>
</html>
If we assume the file you uploaded was a picture called myhouse.jpg, you would then be able to access the picture by going to yourdomain.com/myhouse.jpg
I hope I have interpreted your request correctly and that this is helpful,

Regards

Ian.
celticbrue is offline
Reply With Quote
View Public Profile
 
Old 07-05-2004, 04:37 AM
dbzguy's Avatar
Ultra Talker

Posts: 345
Location: Artic
just make sure php_openbasedir protection is not enbled
__________________
W3 Dynamic Webhosting-Great Hosting, great service, GREAT PRICES!

PHP Code:
<?PHP if(ping == true) { attackuserip(); } ?>
dbzguy is offline
Reply With Quote
View Public Profile Visit dbzguy's homepage!
 
Old 07-05-2004, 12:28 PM
Average Talker

Posts: 26
Run a grammar error php script at your server, you can get the path information at error tips by IE.
rocos is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to how to adress server variables
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.22700 seconds with 12 queries