SitePoint Sponsor

User Tag List

Page 1 of 3 123 LastLast
Results 1 to 25 of 54
  1. #1
    SitePoint Addict michael - ohio's Avatar
    Join Date
    Dec 2004
    Location
    ohio
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    upload path syntax in script - help!

    I've just moved a website from a development server to its new home on a VPS.
    The PHP image upload script was working fine on the old server, but is failing on the new server.

    The path on the server to the target dir is:
    C:\Inetpub\wwwroot\[doman].com\user_images\

    Here's the syntax of the of the upload portion of the script that is not working (reports a failed message from the script).
    Anyone see anything wrong with this???

    $upload_class = new File_Upload('C:\\Inetpub\\wwwroot\\[domain].com\\user_images\\',512000,'0','upload');

    Notes: [domain].com of course is actually the domain name of the website
    and the strings following the path are the parameters for the script.

    Server Environment:
    Windows Server 2003 (64bit)
    PHP 5.3x

    Thanks,
    - Michael

  2. #2
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Without an actual error message from PHP only some soothsayer can help you.

    What a terrible VPS it should be - a windows based one

  3. #3
    SitePoint Addict michael - ohio's Avatar
    Join Date
    Dec 2004
    Location
    ohio
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Shrapnel_N5 View Post
    Without an actual error message from PHP only some soothsayer can help you.
    I appreciate the input - and hope to be able to provide an error log entry soon... however, the question was, is the PATH SYNTAX correct - ie: using the double slash (to escape the dir separator).

    Thanks,

    - Michael

  4. #4
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, it seems to be correct.
    unfortunately, i have no PHP interpreter in my head, so I can't run this code by looking at it and answer your question for sure.
    but you can check it yourself, just by printing this line out

  5. #5
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    I wonder if it's a "real" vs. "virtual" path thing. You are using syntax for the "real" filesystem path, but maybe you need to use the "virtual" - i.e. HTTP - path. Maybe something like

    $upload_class = new File_Upload('/user_images/',512000,'0','upload');

  6. #6
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe you need to use the "virtual" - i.e. HTTP - path.
    for the filename? you kidding?

  7. #7
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    errmmm...
    Quote Originally Posted by michael - ohio View Post
    .....
    The path on the server to the target dir is:
    C:\Inetpub\wwwroot\[doman].com\user_images\
    .....

  8. #8
    SitePoint Addict michael - ohio's Avatar
    Join Date
    Dec 2004
    Location
    ohio
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague View Post
    I wonder if it's a "real" vs. "virtual" path thing. You are using syntax for the "real" filesystem path, but maybe you need to use the "virtual" - i.e. HTTP - path. Maybe something like

    $upload_class = new File_Upload('/user_images/',512000,'0','upload');


    I've tried all sorts of path iterations - but I really need to get the absolute path working so that I know I have PHP installed correctly with the needed extensions. Right now I can't even get useful information from the php_errors.log file (see below) and phpinfo says I'm running PHP 4.x, which I don't understand because I ran the MSIE install for PHP 5.3 (VC9). (see: http://sittercafe.com/phpinfo.php)

    I have a feeling I am going to have to delete everything related to PHP and reinstall from scratch.

    - michael


    ----------------php_errors.log--------------------
    [26-Feb-2010 18:23:44] PHP Warning: Unknown(): (null): Unable to initialize module
    Module compiled with module API=20090626, debug=0, thread-safety=1
    PHP
    [26-Feb-2010 18:23:44] PHP Warning: Unknown(): Unable to load dynamic library 'C:\PHP\ext\php_exif.dll' - The specified module could not be found.
    in Unknown on line 0

  9. #9
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1. Why do you think it's the path that caused your problem?
    2. Do you have C:\PHP\ folder on your hard disk?

  10. #10
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,014
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by michael - ohio View Post
    I've tried all sorts of path iterations - but I really need to get the absolute path working so that I know I have PHP installed correctly with the needed extensions. Right now I can't even get useful information from the php_errors.log file (see below) and phpinfo says I'm running PHP 4.x, which I don't understand because I ran the MSIE install for PHP 5.3 (VC9). (see: http://sittercafe.com/phpinfo.php)
    Does the server have both php4 and php5 installed on it? If so try phpinfo() again but in a file with a .php5 extenstion, the server may be configured to process files that are .php with php version 4.x and files that are .php5 with php version 5.x
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  11. #11
    SitePoint Addict michael - ohio's Avatar
    Join Date
    Dec 2004
    Location
    ohio
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Shrapnel_N5 View Post
    1. Why do you think it's the path that caused your problem?
    2. Do you have C:\PHP\ folder on your hard disk?


    1. I'm just trying to eliminate obvious errors first, like the syntax of the upload path in the script. Since I now know that is correct, I need to make sure that PHP has access to that path. The include_path in PHP.ini is set to:
    .;c:\;c:\php;c:\php\pear

    2. Yes, C:\PHP exists on the server.


    Currently GLOBALS are set to OFF in PHP.ini - I wonder if that's what's biting me?

    Thanks,

    - michael

  12. #12
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Then your script isn't working, you have to debug it, not "eliminate obvious errors".
    You have an error message. Why do you run for anything but not this error message?
    You're waste your own time and other people's time, by asking irrelevant questions.

    You're going totally wrong way.
    There is the only one way to repair a program - debugging. Maximum error reporting and step by step execution.
    If you're not a programmer, you'd better hire one.
    reports a failed message from the script
    What does it say exactly?

  13. #13
    SitePoint Addict michael - ohio's Avatar
    Join Date
    Dec 2004
    Location
    ohio
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SpacePhoenix View Post
    Does the server have both php4 and php5 installed on it? If so try phpinfo() again but in a file with a .php5 extenstion, the server may be configured to process files that are .php with php version 4.x and files that are .php5 with php version 5.x


    As I mentioned in the OP, this is a new VPS set-up - I am configuring it now. We intially set-up PHP 4.x (c:\php\). We also have PHP 5.2 & 5.3 downloaded into folders (c:\php\php5-2\ and c:\php\php5-3\).

    Yesterday I ran the MSIE install script for 5.3 and it didn't solve the problem I'm having with this script - and I was surprised to find that PHPINFO.PHP when run from my website directory still reports PHP Version 4.4.7.

    At this point I think I would benefit from removing all instances of PHP and doing a clean install of PHP 4. (Though I don't know how to do a complete un-install to remove all DLLs!)

    - michael

  14. #14
    SitePoint Addict michael - ohio's Avatar
    Join Date
    Dec 2004
    Location
    ohio
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Shrapnel_N5 View Post
    What does it say exactly?
    It returns the error message for case 1: "There was an error uploading the file to the server."


    ##--------------------------------------------
    ##ERROR FUNCTION
    ##Returns error messages
    ##--------------------------------------------
    function error($num){
    switch($num){
    case '1':
    $err = "There was an error uploading the file to the server.";
    break;
    case '2':
    $err = "The uploaded file was too large - max size is ".round($this->file_max_size/5120)."kb";
    break;
    case '3':
    $err = "This server does not accept the file type you attempted to upload.";
    break;
    case '4':
    $err = "The uploaded file could not be moved from its temporary location.";
    break;
    case '5':
    $err = "The image dimensions were too big.";
    break;
    case '6':
    $err = "This type of image cannot be manipulated.";
    break;
    case '7':
    $err = "An error occured when resizing the image.";
    break;
    }

  15. #15
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Amazing.
    upload path going to use only at [4] but we already have an error at [1].
    It is hard to find a black cat in a dark room, when the cat isn't there.

    Now time to check condition that set this type of error.
    Also these lines at the top of the script would be mighty helpful:
    PHP Code:
    ini_set('display_errors',1);
    error_reporting(E_ALL); 
    And then pray for no @ operators used in the code

  16. #16
    SitePoint Addict michael - ohio's Avatar
    Join Date
    Dec 2004
    Location
    ohio
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by michael - ohio View Post
    As I mentioned in the OP, this is a new VPS set-up - I am configuring it now. We intially set-up PHP 4.x (c:\php\). We also have PHP 5.2 & 5.3 downloaded into folders (c:\php\php5-2\ and c:\php\php5-3\).
    Just discovered that I did indeed screw up the installation of PHP and have 2 different PHP.INI files - one in C:\Windows and one in C:\PHP. The one in C:\windows\ is what is being called. I turned gloabls 'on', but am still getting the same result.

    - michael

  17. #17
    SitePoint Addict michael - ohio's Avatar
    Join Date
    Dec 2004
    Location
    ohio
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Shrapnel_N5 View Post
    It is hard to find a black cat in a dark room, when the cat isn't there.
    Understood and agreed. I was trying to avoid taking up a lot of space in a message with the entire script - but it's a great (old) script and maybe others will find it useful:

    <?php

    ###################################################################################################
    ## File Upload Class - v1.0 ##
    ## http://www.akvoid.com ##
    ## Written By startx - Jacob Wyke ##
    ## startx@aknetwork.org ##
    ###################################################################################################
    ##
    ## This class handles all your file uploading needs. It can handle most file types - you can add
    ## more if needed (just add them to the array in the file_types() function. To use this class
    ## for yourself do the following:
    ##
    ## USAGE:
    ##-------------------------------------------------------------------------------------------------
    ##
    ## include('this_file_name.php');
    ## $upload_class = new File_Upload('upload directory',
    ## 'max_file_size',
    ## 'file__types_array',
    ## 'upload_field_name',
    ## 'upload_fix_prefix'
    ## );
    ##
    ## if(!$_POST[submit]){
    ## #shows the default upload form included with the class - you can make your own
    ## echo $upload_class->default_form('file_upload.php');
    ## }else{
    ## $image[width] = '150'; #max image width
    ## $image[height] = '350'; #max image height
    ## $image[thumbs] = '0'; #make thumbnail of image
    ## $image[thumb_width] = '50'; #thumbnail width
    ## $image[thumb_height] = '50'; #thumbnail height
    ## $image[resize] = '1'; #should images be automatically resized
    ## $image[skip_resize] = '0'; #skip image resizing - shows no "image too big" error
    ##
    ## #processes the submitted form and returns any error or success message
    ## echo $upload_class->process($image);
    ##
    ## #array containing the location of all uploaded files so you can add them to a database/file etc
    ## $uploaded_files = $upload_class->output;
    ## }
    ##
    ##
    ##-------------------------------------------------------------------------------------------------
    ##
    ## The example above shows you how to control the class if you wish to only upload images,
    ## if you want to just upload files to the server then do the same except exclude all the
    ## $image array vars and DO NOT pass it to the "echo $upload_class->process($image);" line
    ##
    ## e.g.
    ## echo $upload_class->process();
    ##
    ##
    ## Further explainations for calling the class
    ##
    ## 'upload directory' - The directory where you want to store the uploaded files
    ## Make sure you make it writable by the server.
    ##
    ## 'max_file_size', - This is the maximum allowed file size to be uploaded in bytes.
    ## Default is set to 51200 which is 500kb
    ##
    ## 'file_types_array' - This is an array containing your own file types. By default
    ## the script allows all the file types shown in the file_types() function
    ## but if you pass your own array of them - then only those types are
    ## allowed. This allows you to limit the types of files. You could of
    ## course just delete any unwanted types from the array in file_types()
    ##
    ## 'upload_field_name' - This is the name of the file field in the form - only use if you
    ## make your own form and dont use the one included in this class.
    ##
    ## 'upload_fix_prefix' - Allows you to add a prefix to all files you upload so that you
    ## can better organise them.
    ##
    ## All of these are optional and so you can just call the class with 'new File_Upload();'
    ##
    ###################################################################################################
    ##
    ## LICENSE
    ##
    ## Please feel free to use/edit this class as you wish but for non-commercial uses ONLY. If
    ## you wish to use it for a commercial product that will be sold then please contact me
    ## further for usage details. You must also keep this license and my contact details attached
    ## somewhere to this class file.
    ##
    ## Other than that please feel free to use and play with it and give me feedback and info
    ## on what your using it for
    ##
    ## Enjoy!
    ##
    ## Jacob Wyke - startx@aknetwork.org
    ##
    ###################################################################################################

    class File_Upload{

    var $allow_types;
    var $field_name;
    var $dir;
    var $file_prefix;
    var $file_max_size;
    var $location;
    var $thumb_location;
    var $output;

    ##--------------------------------------------
    ##CLASS CONSTRUCTOR
    ##--------------------------------------------
    function File_Upload($dir = 'uploads', $size = '512000', $types = '0', $name = 'upload'){
    #creates array of allowed file types if you dont enter your own
    if($types == '0'){
    $this->file_types();
    }else{
    $this->file_types = $types;
    }

    $this->field_name = $name; #name of the upload field in form
    $this->dir = $dir; #name of upload directory
    $this->file_prefix = $_POST['uid']; #file prefix
    $this->file_max_size = $size; #max file size
    $this->output = array (); #makes array to store loction of uploaded files so you know what was uploaded
    }

    ##--------------------------------------------
    ##FILE TYPES FUNCTION
    ##Fills the array with the types of files you want to allow
    ##You can add your own list of file types to the array below
    ##--------------------------------------------
    function file_types(){
    $this->allow_types = array (
    'image/gif',
    'image/x-png',
    'image/jpeg',
    'image/pjpeg',
    );
    }

    ##--------------------------------------------
    ##PROCESS FUNCTION
    ##Processes the file upload
    ##--------------------------------------------
    function process($image = '0'){
    #checks that file was uploaded
    if(!file_exists($_FILES[$this->field_name][tmp_name])){
    return $this->error(1);
    }else{
    #checks that the file isnt too large
    if($_FILES[$this->field_name][size]>$this->file_max_size){
    return $this->error(2);
    }else{
    #checks to see if file type is allowed
    if(!in_array($_FILES[$this->field_name][type],$this->allow_types)){
    return $this->error(3);
    }else{

    if($_FILES[$this->field_name][type]=='image/gif')
    $ext='.gif';
    if($_FILES[$this->field_name][type]=='image/x-png')
    $ext='.png';
    if($_FILES[$this->field_name][type]=='image/jpeg')
    $ext='.jpg';
    if($_FILES[$this->field_name][type]=='image/pjpeg')
    $ext='.jpg';

    #Repeat loop till you find an available file name
    $loop = '0';
    do{
    $loop++;
    #create new file location
    if(file_exists($this->dir."/".$this->file_prefix.".jpg"))
    unlink($this->dir."/".$this->file_prefix.".jpg");
    if(file_exists($this->dir."/".$this->file_prefix.".gif"))
    unlink($this->dir."/".$this->file_prefix.".gif");
    if(file_exists($this->dir."/".$this->file_prefix.".png"))
    unlink($this->dir."/".$this->file_prefix.".png");

    $this->location = $this->dir."/".$this->file_prefix.$ext;

    if(file_exists($this->dir."/".$this->file_prefix."_t".".jpg"))
    unlink($this->dir."/".$this->file_prefix."_t".".jpg");
    if(file_exists($this->dir."/".$this->file_prefix."_t".".png"))
    unlink($this->dir."/".$this->file_prefix."_t".".png");
    if(file_exists($this->dir."/".$this->file_prefix."_t".".gif"))
    unlink($this->dir."/".$this->file_prefix."_t".".gif");

    $this->thumb_location = $this->dir."/".$this->file_prefix."_t".$ext;
    }while(file_exists($this->location));

    #processes file for image stuff
    if($image){
    $outcome = $this->process_image($image);
    if(!$image[skip_resize]){ #dont need to rename the orignal as we have skipped the resizing
    $this->location = $this->dir."/orig_".$loop."_".$this->file_prefix.$_FILES[$this->field_name][name];
    }
    }

    if($outcome){
    #returns any errors from the image function
    return $outcome;
    }else{
    return "1";
    }
    }
    }
    }
    }

    ##--------------------------------------------
    ##PROCESS IMAGE FUNCTION
    ##Processes images
    ##--------------------------------------------
    function process_image($image){
    #gets the image dimensions
    $size = getimagesize($_FILES[$this->field_name][tmp_name]);
    #makes sure the image isnt larger than your max width/height
    if((($size[0]>$image[width]) OR ($size[1]>$image[height])) AND !$image[resize] AND !$image[skip_resize]){
    return $this->error(5);
    }else if(($size[0]>$image[width]) OR ($size[1]>$image[height]) AND $image[resize]){
    #resize the image if wanted
    if(!$image[skip_resize]){
    $height=(int)(($image[width]*$size[1])/$size[0]);
    $this->make_image($this->location, $image, $size, $image[width], $height);
    }
    }else{
    #send image as is if no resize is needed
    $this->make_image($this->location, $image, $size, $size[0], $size[1]);
    }

    #make thumbnail of image if needed
    if($image[thumbs]){
    $this->make_image($this->thumb_location, $image, $size, $image[thumb_width], $image[thumb_height]);
    }
    }

    ##--------------------------------------------
    ##MAKE IMAGE FUNCTION
    ##Makes image
    ##--------------------------------------------
    function make_image($location, $image, $size, $width, $height){
    if($_FILES[$this->field_name][type]=='image/gif'){
    if(function_exists('imagecreatefromgif')){
    $im = @imagecreatefromgif($_FILES[$this->field_name][tmp_name]);
    }else{
    echo $this->error(6);
    exit;
    }
    }
    if($_FILES[$this->field_name][type]=='image/jpeg' OR $_FILES[$this->field_name][type]=='image/pjpeg'){
    if(function_exists('imagecreatefromjpeg')){
    $im = @imagecreatefromjpeg($_FILES[$this->field_name][tmp_name]);
    }else{
    echo $this->error(6);
    exit;
    }
    }
    if($_FILES[$this->field_name][type]=='image/x-png'){
    if(function_exists('imagecreatefrompng')){
    $im = @imagecreatefrompng($_FILES[$this->field_name][tmp_name]);
    }else{
    echo $this->error(6);
    exit;
    }
    }

    if(!$im){
    echo $this->error(7);
    exit;
    }else{
    $dst_img = imagecreatetruecolor($width,$height);
    imagecopyresized($dst_img, $im, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
    imagejpeg($dst_img, $location, 75);
    array_push($this->output, $location);
    }
    }

    ##--------------------------------------------
    ##ERROR FUNCTION
    ##Returns error messages
    ##--------------------------------------------
    function error($num){
    switch($num){
    case '1':
    $err = "There was an error uploading the file to the server.";
    break;
    case '2':
    $err = "The uploaded file was too large - max size is ".round($this->file_max_size/5120)."kb";
    break;
    case '3':
    $err = "This server does not accept the file type you attempted to upload.";
    break;
    case '4':
    $err = "The uploaded file could not be moved from its temporary location.";
    break;
    case '5':
    $err = "The image dimensions were too big.";
    break;
    case '6':
    $err = "This type of image cannot be manipulated.";
    break;
    case '7':
    $err = "An error occured when resizing the image.";
    break;
    }
    return $err;
    }

    ##--------------------------------------------
    ##DEFAULT FORM FUNCTION
    ##Shows a very basic form for the upload
    ##--------------------------------------------
    function default_form($action, $class = '', $button_class = ''){
    $text = "
    <form method='POST' action='$action' name='file_upload' enctype='multipart/form-data'>
    File: <input class='$class' type='file' name='upload' size='25'>
    <br />
    <input type='hidden' value='414' name='uid'>
    <input class='$button_class' type='submit' name='submit' value='Upload'>
    </form>
    ";
    return $text;
    }

    }




    if($_POST['uid'])
    { $upload_class = new File_Upload('C:\\Inetpub\\wwwroot\\[foo.com]\\user_images\\',1548576,'0','upload');

    $image[width] = "150"; #max image width
    $image[height] = "350"; #max image height
    $image[thumbs] = "1"; #make thumbnail of image
    $image[thumb_width] = "50"; #thumbnail width
    $image[thumb_height] = "50"; #thumbnail height
    $image[resize] = "1"; #should images be automatically resized
    $image[skip_resize] = "0"; #skip image resizing - shows no "image too big" error

    $result = $upload_class->process($image);
    if($result=="1")
    header("Location: ./sitter_main.asp");
    else
    header("Location: ./sysmsg.asp?msg=".$result);
    }


    ?>

  18. #18
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    was trying to avoid taking up a lot of space in a message with the entire script
    you were right
    debugging stands for running script, not reading it.

    As I can see it raises this error with this check:
    PHP Code:
    if(!file_exists($_FILES[$this->field_name][tmp_name])){ 
    It can say not too much, so i'd suggest to add this line somewhere in the script:
    PHP Code:
    echo "<pre>"
    print_r($_FILES);
    echo 
    "</pre>"
    it will tell you everything about uploaded file and possible errors

    this script is full of errors at glance.
    You can not use some powerful techniques on it.

  19. #19
    SitePoint Addict michael - ohio's Avatar
    Join Date
    Dec 2004
    Location
    ohio
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Shrapnel_N5 View Post
    this script is full of errors at glance.
    We've been using it successfully without errors for 5 years on our old server environment (WS2K3/PHP4). If at all possible I'd like to get it working. Otherwise I'll have to turn to another more current script.

    We use this to allow registered and signed in website users to upload a single image: the script resizes the image and creates a thumbnail and saves the two files as [UserID.ext] and [UserID_t.ext].

    A newer script would probably make use of the GD2 library and add the ability to add a site watermark - things like that. Eventually it will be worth it - but right now I'm just trying to get the image uplaod feature of the site working again.

    I'll add the code you've suggested.

    Thanks,

    - Michael

  20. #20
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you have a car without steering wheel you can ride it 5 miles or more, as long as road has no turns. But then you'd realize that something wrong.

  21. #21
    SitePoint Addict michael - ohio's Avatar
    Join Date
    Dec 2004
    Location
    ohio
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Shrapnel_N5 View Post
    add this line somewhere in the script:
    PHP Code:
    echo "<pre>"
    print_r($_FILES);
    echo 
    "</pre>"
    Tried adding the code to the script (just above the error functions section) as:
    {
    echo "<pre>"; print_r($_FILES);echo "</pre>";
    }

    and then as:

    echo "<pre>"; print_r($_FILES);echo "</pre>";

    but when the script is called from the form (in the browser), neither returned anything different than the error text provided for in the script. Obviously I have no idea what I am doing.

    I do not want to waste your time - and appreciate your input thus far. If you're available to assist on a formal basis ($) feel free to PM me.

    Thanks,

    - Michael

  22. #22
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh yeah I see. It's a class, not a running script
    so, add it to the constructor:
    Code:
    ##--------------------------------------------
    ##CLASS CONSTRUCTOR
    ##--------------------------------------------
    function File_Upload($dir = 'uploads', $size = '512000', $types = '0', $name = 'upload'){
    echo "<pre>"; 
    print_r($_FILES);
    echo "</pre>"; 
    die();
    #creates array of allowed file types if you dont enter your own
    if($types == '0'){
    $this->file_types();
    }else{
    $this->file_types = $types;
    }
    Now it should print very useful info

  23. #23
    SitePoint Addict michael - ohio's Avatar
    Join Date
    Dec 2004
    Location
    ohio
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Shrapnel_N5 View Post
    Oh yeah I see. It's a class, not a running script so, add it to the constructor:
    result:

    Array
    (
    [upload] => Array
    (
    [name] => michael-sig.jpg
    [type] => image/pjpeg
    [tmp_name] => C:\WINDOWS\Temp\php30.tmp
    [error] => 0
    [size] => 1976
    )

    )

  24. #24
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now i'm in trouble.
    Second attempt in remote debugging and fail again.
    Everything seems to be o.k...

    error in the file_exists function may be?
    try to change this line
    PHP Code:
    if(!file_exists($_FILES[$this->field_name][tmp_name])){ 
    to this
    PHP Code:
    if(!$_FILES[$this->field_name][tmp_name]){ 
    and run again, but first remove previous code - with print_r and die one

  25. #25
    SitePoint Addict michael - ohio's Avatar
    Join Date
    Dec 2004
    Location
    ohio
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Shrapnel_N5 View Post
    change this line
    PHP Code:
    if(!file_exists($_FILES[$this->field_name][tmp_name])){ 
    to this
    PHP Code:
    if(!$_FILES[$this->field_name][tmp_name]){ 
    returned:
    This type of image cannot be manipulated.

    which isn't the case - it was a small jpg that the script has handled just fine in the past.

    - michael


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •