PHP upload directory

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
BloodDragon
-


Joined: 12 Aug 2007
Posts: 1

PostPosted: Sun Aug 12, 2007 6:47 pm    Post subject: PHP upload directory Reply with quote

I am currently using Abyss Web Server X1 for testing my website offline. I've been trying to use an easy php script for uploading. The problem I'm having is that when a file is uploaded to a relative location, the file is saved to the php program files folder, instead of the scripts directory.

How can I save an uploaded file to a specific directory in my website location, without giving the exact location of the upload directory, but using a relative path?

This is my test-script:
Code:

<?php
if (($_FILES["file"]["type"] == "image/gif")
    || ($_FILES["file"]["type"] == "image/pjpeg")
    && ($_FILES["file"]["size"] < 20000))
{
    if ($_FILES["file"]["error"] == 0)
    {     
        $targetPath = "./" . $_FILES["file"]["name"];
       
        if (!file_exists($targetPath))
            move_uploaded_file($_FILES["file"]["tmp_name"], $targetPath);
    }
}
?>
Back to top View user's profile Send private message
admin
Site Admin


Joined: 03 Mar 2002
Posts: 1332

PostPosted: Mon Aug 13, 2007 12:42 am    Post subject: Re: PHP upload directory Reply with quote

BloodDragon,

The documents path is provided to your script in $_SERVER['DOCUMENT_ROOT']. So you can use it to build the value of $targetPath.
_________________
Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group