Link to home
Start Free TrialLog in
Avatar of jrcygnus
jrcygnus

asked on

PHP: How do I get an uploaded file from the temp folder to an actual ('upload_test') folder?

Hi ,
I can test my script below on the local server, but it does not work on the live site. My host told me the directory is /home/sites/www.foreveryoungchiro.ca/web/upload_test, but it just never uploads to me 'upload_test' folder?

Can anyone see what is wrong?
<?php
if (array_key_exists('upload', $_POST)) {
// define constant for upload folder
define('UPLOAD_DIR',  '/home/sites/www.foreveryoungchiro.ca/web/upload_test/');
 
 
// move the file to the upload folder and rename it
move_uploaded_file($_FILES['image']['tmp_name'], UPLOAD_DIR.$_FILES['image']['name']);
}
?>
 
 
 
As seen below it successfully loads to the tmp folder but how do I redirect it for stay permanently on a site folder?
Upload image: 
 
Array
(
    [image] => Array
        (
            [name] => ist2_1566514-grandfather-with-grandson-under-cloudfield.jpg
            [type] => image/pjpeg
            [tmp_name] => /tmp/phpKRNOgP
            [error] => 0
            [size] => 48660
        )
 
)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of basic612
basic612
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of shobinsun
shobinsun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jrcygnus
jrcygnus

ASKER

Thanks guys!
I was not quite sure what 777 was, but I looked it up and began to understand about permission settings.
I am going to add more script to check for file types and size, but I just wanted to keep it simple for now until I could find out why nothing was uploading.