How come cannot insert image in this folder?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
teckyan888
Forum Commoner
Posts: 40
Joined: Tue May 11, 2004 10:46 am

How come cannot insert image in this folder?

Post by teckyan888 »

Code: Select all

<?php
C:\Program Files\Apache Group\Apache2\htdocs\assign <--This is my homepage

C:\Program Files\Apache Group\Apache2\htdocs\assign\image  <--This is my folder to insert image...

$imgf = $_FILES['userfile']['name']; // name of file in user's machine

$fileDir = "image/".$imgf;   <--this is my file dir

?>
Any mistake from my $filedir??
how come i cannot insert the image inside this $filedir???
Anyone who know how to solve it???
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

Do you have permission from the filesysytem to insert the image?

see here
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Also define 'insert the image'. It looks like it's a file upload as your using $_FILES, in which case does 'insert the image' mean using move_uploaded_file() ? Might need to see that part of the code too ;)
teckyan888
Forum Commoner
Posts: 40
Joined: Tue May 11, 2004 10:46 am

Post by teckyan888 »

Code: Select all

<?php
$imgf = $_FILES['userfile']['name']; // name of file in user's machine
$imgt = $_FILES['userfile']['type']; // type of uploaded file
$imgs = $_FILES['userfile']['size']; // size of uploaded file, in bytes
$imgtf = $_FILES['userfile']['tmp_name'];  // name of the file temporarily 
                                           // stored in server
$fileError = $_FILES['userfile']['error']; // error code in uploading file, 
                                           // 0 - success

if ($fileError != UPLOAD_ERROR_OK)
{
    echo 'Error in uploading: ';
    switch ($fileError)
    {
        case UPLOAD_ERR_INI_SIZE:
            echo 'File exceeded upload_max_filesize</br>';
            ReturnToBack();exit();

        case UPLOAD_ERR_FORM_SIZE:
            echo 'File exceeded max_file_size</br>';
            ReturnToBack();exit();

        case UPLOAD_ERR_PARTIAL:
            echo 'File only partially uploaded</br>';
            ReturnToBack();exit();

        case UPLOAD_ERR_NO_FILE:
            echo 'No file uploaded</br>';
            ReturnToBack();exit();
    }
}
else
{  

$fileDir = "image/".$imgf;            <-----------------HERE
// current folder's sub-subfolder! 
// script in htdocs/kokch
 // image loaded in htdocs/kokch/imgFolder/image 

} 

?>
Actually if i put all my page inside HTDOCS and CREATE NEW FOLDER CALLED image,i can insert the image inside the FOLDER........But problem is,When i create a new folder called "assign" and inside the "assign" got a folder called "image"...I cannot upload the image in the "assign/image" folder...Why??
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

missing the complete path to the folder outside of the root...
Post Reply