Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Pages: [1]
Send this topic | Print
Topic: Upload script problem :\  (Read 1830 times)
« on: January 25, 2005, 01:47:25 AM »
TheDarkness
Guest

I have an upload script setup, but when I goto test it and upload a test picture it just sits there with the status bar going and never uploads the file. Can someone help me out? :X

Code:


$site_name = $_SERVER['HTTP_HOST'];
$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$url_this =  "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

$upload_dir = "/images/screenshot/";
$upload_url = $url_dir."screenshot/";
$message ="";

//create upload_files directory if not exist
//If it does not work, create on your own and change permission.
if (!is_dir("images/screenshot")) {
die ("upload_files directory doesn't exist");
}

if ($_FILES['userfile']) {
$message = do_upload($upload_dir, $upload_url);
}
else {
//$message = "Invalid File Specified.";
}

print $message;

function do_upload($upload_dir, $upload_url) {

$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_type = $_FILES['userfile']['type'];
$file_size = $_FILES['userfile']['size'];
$result    = $_FILES['userfile']['error'];
$file_url  = $upload_url.$file_name;
$file_path = $upload_dir.$file_name;

//File Name Check
    if ( $file_name =="") {
    $message = "Invalid File Name Specified";
    return $message;
    }
    //File Size Check
    else if ( $file_size > 700000) {
        $message = "The file size is over 700kb.";
        return $message;
    }
    //File Type Check
    else if ( $file_type == "text/plain" || $file_type == "exe" || $file_type == "zip" || $file_type == "rar") {
        $message = "Sorry, You are only allowed to upload files of gif,jpg,jpeg or png type." ;
        return $message;
    }

    $result  =  do_upload($temp_name, $file_path);
    $message = ($result)?"File url $file_url" :
         "Somthing is wrong with uploading a file.";

    return $message;
}

?>

  Upload Image
 

Report to moderator   Logged

 
« Reply #1 on: January 27, 2005, 09:26:05 PM »
adragons
Guest

Hm... I cant seem to get it working. I'll have to re-write most of it. For somereason I cant get it working. I had an upload script on my pc before... Im working on it just uploads are exceedingly difficult for something so simple.
Report to moderator   Logged
« Reply #2 on: January 29, 2005, 10:57:26 PM »
adragons
Guest

Bump:
 
I know what your missing but it wont seem to work.
move_uploaded_file()
This will move it from the servers temp upload dir to yours.
for some reason, what ever it may be, I can't make it work =/
 
edit: Yours probably 'just sits there' beacause you are calling the do_upload function from within its self when you say
$result = do_upload();
Report to moderator   Logged
« Reply #3 on: February 02, 2005, 09:01:29 AM »
Junior Member
salemba Offline
Junior Member
Newbie

View Profile
*
Posts: 2



hmm... can i get just one "simple" examples how to upload files ini this host... coz i cant upload files... Sad

Thanks for help tongue
Report to moderator   Logged
 
Pages: [1]
Send this topic | Print
Jump to:  

Powered by SMF | SMF © 2006-2008, Simple Machines LLC