Results 1 to 24 of 24

Thread: Upload files with PHP [Resolved*3]

  1. #1

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Upload files with PHP [Resolved*3]

    And here we go again. More or less just me asking questions here now...

    I found an example in my Beginning PHP4 book from wrox on how to upload files to the server. But the explenation is a bit hard to understand. Here is the code

    PHP Code:
    <?
    //file_upload.php
    $archive_dir = "./bildebox";
    function upload_form() {
       global $PHP_SELF;
    ?>
    <FORM METHOD="POST" ENCTYPE="MULTIPART/FORM-DATA" 
       ACTION="<? echo $PHP_SELF ?>">
       <INPUT TYPE="HIDDEN" NAME="action" VALUE="upload">
       Upload file!
       <INPUT TYPE="FILE" NAME="userfile">
       <INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="upload">
    </FORM>
    <?
    }

    function upload_file() {
       global $userfile, $userfile_name, $userfile_size, 
             $userfile_type, $archive_dir, $WINDIR;

       if(isset($WINDIR)) $userfile = str_replace("\\\\","\\", $userfile);
       
       $filename = basename($userfile_name);
       
       if($userfile_size <= 0) die ("$filename is empty.");

       if(!@copy($userfile, "$archive_dir/$filename"))
          die("Can't copy $userfile_name to $filename.");
       
       if(!isset($WINDIR) && !@unlink($userfile))
          die ("Can't delete the file $userfile_name.");

       echo "$filename has been successfully uploaded.<BR>";
       echo "Filesize: " . number_format($userfile_size) . "<BR>";
       echo "Filetype: $userfile_type<BR>";
    }
    ?>
    <HTML>
    <HEAD><TITLE>FILE UPLOAD</TITLE></HEAD>
    <BODY>
    <?
    if($action == 'upload') upload_file();
    else upload_form();
    ?>
    </BODY>
    </HTML>
    In my "public_html" folder, I have a folder called "klubbny", in that folder I have two folders. One called "oppdater" where I have this page, and one called bildebox, where I want to upload the file to.

    What am I doing wrong here. I am getting the message:

    Can't copy f.gif to f.gif.
    Am my link in the top:

    $archive_dir = "./bildebox";

    wrong...should I write the whole path, or what. Not getting the path system here completly.

    Thanks ØØ
    Last edited by NoteMe; Apr 18th, 2004 at 02:09 PM.

  2. #2

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    And an other thing that concerns me is that I want to use it as vbforums does. Have a lot of other textboxes and stuff to, and not uplad it before it goes to the next page. Is that possible?

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Its clear that the copying of the uploaded file is failing. This may be due to the fact that you are using the relative path as your $archive_dir and your PHP script is not executing in the directory you expect your PHP script to be in.

    Modify your source so you can get some debugging information:
    PHP Code:
    if(!copy($userfile"$archive_dir/$filename")) {
        echo (
    'Current directory: ' getcwd () . '<br />');
        die(
    "Can't copy $userfile_name to $filename.");

    That should cause the script to spit out whatever error message is being generated by the copy function and also print the current working directory of the script.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    eww, register_globals is on?

    This line should be making your entire thing not work:
    PHP Code:
    if(isset($WINDIR)) $userfile str_replace("\\\","\\", $userfile); 
    If you have warnings/errors turned off, you may not have caught that.

    I don't know what you mean by having it "not upload until it goes to the next page".. You can add other form elements to your page, and also have your upload function do any uploading, but only if it's necessary. You don't have to have a form that's just for uploading.

    If you're interested, this is what I use for uploading things, and with a few modifications you can have a nice uploader..
    PHP 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 = "upload_files/";
      $upload_url = $url_dir . "/" . $upload_dir;
      $message ="";

      if($_FILES['userfile']){
        $message = do_upload($upload_dir, $upload_url);
      }else{
        $message = "Invalid File Specified.";
      }
      echo $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."gay" . $file_name;
        if($file_name == "") {
          $message = "Error: Invalid filename.";
          return $message;
        }elseif($file_size > 500000){
          $message = "Error: Filesize exceeds 500K.";
          return $message;
        }elseif($file_type == "text/plain") {
          $message = "Error: Unable to upload plain text files." ;
          return $message;
        }
        $result = move_uploaded_file($temp_name, $file_path);
        $message = ($result) ? "File Location: <a href=$file_url>$file_url</a>" : "There was an error while uploading the file.";
        return $message;
      }
    ?>
    <form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post">
      Upload Image<input type="file" id="userfile" name="userfile">
      <input type="submit" name="upload" value="Upload File">
    </form>
    Like Archer? Check out some Sterling Archer quotes.

  5. #5

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by visualAd
    Its clear that the copying of the uploaded file is failing. This may be due to the fact that you are using the relative path as your $archive_dir and your PHP script is not executing in the directory you expect your PHP script to be in.

    Modify your source so you can get some debugging information:
    PHP Code:
    if(!copy($userfile"$archive_dir/$filename")) {
        echo (
    'Current directory: ' getcwd () . '<br />');
        die(
    "Can't copy $userfile_name to $filename.");

    That should cause the script to spit out whatever error message is being generated by the copy function and also print the current working directory of the script.

    Thanks, that gave me some more info. And it looks like the problem is that I am not good enought to find the right directory...


    I have to go up one level, then down again into an other folder called "bildebox".

    I thought I could just write

    $archive_dir = "./bildebox";

    to go down one level, and then up again. But it now looks like it is trying to find ./bildebox in my current folder. So what do I have to write in front of the /bildebox to make it go up one folder before it goes down to the right one.

  6. #6

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by kows
    eww, register_globals is on?

    This line should be making your entire thing not work:
    PHP Code:
    if(isset($WINDIR)) $userfile str_replace("\\\","\\", $userfile); 
    If you have warnings/errors turned off, you may not have caught that.
    I can see that vBulletin boards have skiped some \ at this line, when I colpied pasted. It is actualy 4 \ at the first parameter, then 2 in the second one. Not sure what $WINDIR is anyway, but to me it looks like that line is converting from a unix path to a windows path. Not sure what oyu ment that it will make my code fail.


    Originally posted by kows

    If you're interested, this is what I use for uploading things, and with a few modifications you can have a nice uploader..
    PHP 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 = "upload_files/";
      $upload_url = $url_dir . "/" . $upload_dir;
      $message ="";

      if($_FILES['userfile']){
        $message = do_upload($upload_dir, $upload_url);
      }else{
        $message = "Invalid File Specified.";
      }
      echo $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."gay" . $file_name;
        if($file_name == "") {
          $message = "Error: Invalid filename.";
          return $message;
        }elseif($file_size > 500000){
          $message = "Error: Filesize exceeds 500K.";
          return $message;
        }elseif($file_type == "text/plain") {
          $message = "Error: Unable to upload plain text files." ;
          return $message;
        }
        $result = move_uploaded_file($temp_name, $file_path);
        $message = ($result) ? "File Location: <a href=$file_url>$file_url</a>" : "There was an error while uploading the file.";
        return $message;
      }
    ?>
    <form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post">
      Upload Image<input type="file" id="userfile" name="userfile">
      <input type="submit" name="upload" value="Upload File">
    </form>
    This code looks much better then the one I found. Even if it called my file gay after it was uplaoded.......but the problem with going up one folder level before down in an other folder is still the same.

  7. #7

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I have made a picture so you can see more clear what I mean with the folders.




    My PHP file is in the "oppdater" folder. Then I guess I have to write this line:

    $archive_dir = "./bildebox";

    in a way that it makes it go up to "klubbny" then down in the other folder called "bildebox".

  8. #8
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    $archive_dir = "../bildebox"

    One dot . corresponds to the current directory and two dots .. refers to the parent directory.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  9. #9

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Hehe...ok...thanks...but actually I tried that yesterday.

    And it didn't work. So there must be an other problem.

    I get a permission denied error. But on the folder I have the read/write/execute persmissions, so it can't be that...

    Warning: copy(../bildebox/f.gif): failed to open stream: Permission denied in /home/klub/public_html/klubbny/oppdater/file_upload.php on line 27
    Current directory: /home/klub/public_html/klubbny/oppdater
    Can't copy f.gif to f.gif.

  10. #10

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    And KOWS code gives me this error:

    Warning: move_uploaded_file(../bildebox/gayf.gif): failed to open stream: Permission denied in /home/klub/public_html/klubbny/oppdater/upload3.php on line 35

    Warning: move_uploaded_file(): Unable to move '/tmp/php0UudLu' to '../bildebox/gayf.gif' in /home/klub/public_html/klubbny/oppdater/upload3.php on line 35
    There was an error while uploading the file.
    I am so lost now. This is things that we don't learn at school, but that we should have learned...

  11. #11
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    You need to make that directory world writeable otherwise PHP cannot create the file.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  12. #12
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Are you on Windows or Unix???

    For some reason I thought you were on Windows :::slaps himself:::

    It depends on how ther server has been set up. The error is caused becuase the PHP process does not have permission to create files in that directory.

    I think what you'll have to do is either create the directory using PHP, so as it is automatically owned by the httpd/php use and group and then it should work. Or if you can change the permissions on the directory making it world writeable.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  13. #13

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Thanks, then it finaly worked.

    I thought that was pretty scary to do. But I guess as long as no other then the admins know about that folder, it can't be miss used. Or what?

    f.gif has been successfully uploaded.
    Filesize: 4,951
    Filetype: image/gif

    Will go off and try to make all the other fields work on the same page now. Thanks for all your help, both of you.

    ØØ

  14. #14

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by visualAd
    Are you on Windows or Unix???

    For some reason I thought you were on Windows :::slaps himself:::

    It depends on how ther server has been set up. The error is caused becuase the PHP process does not have permission to create files in that directory.

    I think what you'll have to do is either create the directory using PHP, so as it is automatically owned by the httpd/php use and group and then it should work. Or if you can change the permissions on the directory making it world writeable.

    I made it public writebal, and then it worked. But I guess it is more safe to make PHP create it. So PHP can be in the group, rather then make it writebal for everyone.

    Thanks

  15. #15
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Originally posted by NoteMe
    But I guess as long as no other then the admins know about that folder, it can't be miss used. Or what?
    If you've had to make the folder world writeable, it is best to put it outisde the document root so only your PHP script can get to it.

    If you are the admin of the server though you can always set it up so that PHP runs under a different user from the web server and chown all your web server files to the user which the PHP script runs under.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  16. #16

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    THanks, but I am not the admin at that server. Not sure how they have set up that server. I am just trying to help a friend out here with his page, becuase I soon have my exam in PHP, and I just found out that I suck.....so I had to start somewhere.


    But I will figgure out something to make it safe anyway. Thanks for everything.

  17. #17

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    OK...last Q about this topic...

    I have now one PHP file, that first makes you upload a file, then when you press upload, it uplaods the file, and then the rest of the form are made so you can write text an stuff that later will be stored in a MySQL database.

    But in the function where I am uploading the file, I am also making the other text fields and so on. And in one of those I want the name of the file I uploaded. But how do I add the name of the file in that text field. Here is the striped down code for just this:

    PHP Code:
    function upload_file() {
       global $userfile, $userfile_name, $userfile_size, 
             $userfile_type, $archive_dir, $WINDIR;

       if(isset($WINDIR)) $userfile = str_replace("\\\\","\\", $userfile);
       
       $filename = basename($userfile_name);
       
       if($userfile_size <= 0) die ("$filename is empty.");

       if(!copy($userfile, "$archive_dir/$filename")) {
        echo ('Current directory: ' . getcwd () . '<br />');
        die("Can't copy $userfile_name to $filename.");
       }
       
       if(!isset($WINDIR) && !@unlink($userfile))
          die ("Can't delete the file $userfile_name.");

    ?>

    <form method="get" action="ferdig_linkk.php" style="margin:0; padding:0">

    <div id="Info">
    Bildefilen:
    [b]<input type="text" name="lBilde" size="60" value="<? "$filename" ?>"/>[/b]

    </div>

    </form>
    <?
    }
    ?>
    I have bolded out the line where I am trying to get the file name in the text field using the value property.

  18. #18

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I am sutch a short thinker. An echo did it for me...



    Code:
    <input type="text" name="lBilde" size="60" value="<? echo "$filename";?> "/>

  19. #19
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    Use a shortcut;
    PHP Code:
    <input type="text" name="lBilde" size="60" value="<?=$filename;?>" />
    Also, I was literally laughing out loud when I read that my uploader had called your file gay, but it's because of this line:
    PHP Code:
    $file_path $upload_dir."gay" $file_name
    I was having trouble changing a lot of stuff with the original script, so I added that as an error check while changing it and never noticed I still had it there.
    Like Archer? Check out some Sterling Archer quotes.

  20. #20

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Thanks for the short cut.


    And when I saw that gay thingy, I though you thought my skills in PHP was so bad that you just wrote that to give me a hidden message.......good to hear you didn't mean to have that extra name to my files...


    BTW: I am still working on the page, and have been sitting for an hour now with the same "error". First of all I am using:

    printf("<tr><td>%s</td><td>%s</td></tr>\n",$Overskrift, $Dato);

    To make a small table so the headings get pretty. But I want the right cell to be right aligned and the left one to be left aligned. But I can't manage it. Why can't I just put in a nice align="right on the right <td>???

    The other thing is that I am getting both the heading and the rest of the text from MySQL and print it in a "visual" box. I want the heading in one font, and the rest with an other one. But since I want it to apear in that "visual" box, I have to use CSS to align it to that box, so I have one div that places it in that box, and then I have an other one inside that to make the heading in an other font (that one is not placing it in any position. But in IE, it doesn't care about my inner div, it prints everything according to the outhers property.

    The two divs look like this:

    Code:
    h2{
    	position:absolute;
    	left:7px;
    	top:25px;	
    	width:358px;
    	height:477px;
    	font-size: 10px;
    	font-weight: normal;
    	font-family: Arial, Helvetica, Verdana, sans-serif;
    	z-index:38;
    	visibility: visible;
    	font-size: 11px;
    	overflow: auto;
    	padding: 0 0 0 0;
    	margin: 0 0 0 0;
    }
    
    verdana{
    	font-size: 11px;
    	font-weight: bold;
    	font-family:  Helvetica, Verdana, Arial, sans-serif;
    	font-style: normal;
    	font-variant: normal;
    	color: #000000;
    }
    here is a link to the page if you don't understand what I mean. (I am updating all the time, so it might look diffrent from time to time, and even some errors can ocour...

    http://www.klubbscenen.com/klubbny/

  21. #21

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Not sure how nice it looks, but I fixed the table problem adding

    "<p align=right>"

    to the text that I are putting in to the right cell...

  22. #22

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I fixed the other problem too. IE don't like CSS and I hate that since most users are using IE....

  23. #23
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Posted by kows
    eww, register_globals is on?

    This line should be making your entire thing not work:
    PHP Code:
    if(isset($WINDIR)) $userfile str_replace("\\\","\\", $userfile); 
    If you have warnings/errors turned off, you may not have caught that.

    I don't know what you mean by having it "not upload until it goes to the next page".. You can add other form elements to your page, and also have your upload function do any uploading, but only if it's necessary. You don't have to have a form that's just for uploading.

    If you're interested, this is what I use for uploading things, and with a few modifications you can have a nice uploader..
    PHP 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 = "upload_files/";
      $upload_url = $url_dir . "/" . $upload_dir;
      $message ="";

      if($_FILES['userfile']){
        $message = do_upload($upload_dir, $upload_url);
      }else{
        $message = "Invalid File Specified.";
      }
      echo $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."gay" . $file_name;
        if($file_name == "") {
          $message = "Error: Invalid filename.";
          return $message;
        }elseif($file_size > 500000){
          $message = "Error: Filesize exceeds 500K.";
          return $message;
        }elseif($file_type == "text/plain") {
          $message = "Error: Unable to upload plain text files." ;
          return $message;
        }
        $result = move_uploaded_file($temp_name, $file_path);
        $message = ($result) ? "File Location: <a href=$file_url>$file_url</a>" : "There was an error while uploading the file.";
        return $message;
      }
    ?>
    <form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post">
      Upload Image<input type="file" id="userfile" name="userfile">
      <input type="submit" name="upload" value="Upload File">
    </form>
    Sorry to dig up this thread but is there a a reason the size limit is 500KB here? Like is it something top do with timing out or something? Or could I change it to a really big number and it will still work?
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  24. #24

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by Electroman
    Sorry to dig up this thread but is there a a reason the size limit is 500KB here? Like is it something top do with timing out or something? Or could I change it to a really big number and it will still work?

    I have no limit on my site now...and it works...but I havn't tried realy big files wither. Not sure about the timeout. I am not that into how a browser works, but I guess it will work ok.

Posting Permissions

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



Click Here to Expand Forum to Full Width