SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Zealot Teraflops's Avatar
    Join Date
    Apr 2002
    Location
    NYC
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Upload image script needs help

    I find my self once again struggling with yet another image upload
    script.Everything in this script seems to perform well, except for the
    main task it suppose to perform...Uploading the image name into the
    database and uploading the picture into the desire save path. Can some
    one please help me out with this ?

    PHP Code:
    <?php
    if ($submit): 
    include (
    '../../config/one_config.php');     

    // upload image to server and add filename to database
            
    if (!is_uploaded_file($image)){ // no image
            
    $image_filename "NULL"//file type unknown
            
    echo "Sorry, but this file type is not recognised as an image, please check and try <a href=""\"java script: history.go(-1)\">again</a>.<br>";
            exit ();
      
            } else { 
    // validates image type, rename and save image
            
                
    if ($HTTP_POST_FILES['image']['type'] == "image/gif" || $HTTP_POST_FILES['image']['type'] == "image/jpeg" || $HTTP_POST_FILES['image']['type'] == "image/jpg" || $HTTP_POST_FILES['image']['type'] == "image/pjpeg"){
                
                
    chmod('\OneXsquare\lk_image'777); 
       
    $time_tmp time();
                
    $image_filename $time_tmp._.$HTTP_POST_FILES['image']['name'];
                
    $image_savepath $HTTP_SERVER_VARS['DOCUMENT_ROOT']."\OneXsquare\lk_image";
                
                
    move_uploaded_file($image$image_savepath);
                
                } 
            }

     
    $dbcnx=mysql_pconnect($localhost,$username,$password);
     
    mysql_select_db("$linkdb");
     
    $sql=("INSERT INTO linkage (id,name,email,url,todaycount,totalcount,timestamp,created, picname)"."VALUES ('NULL', '$name', '$email', '$url', '0', '0', now(), now(), '$image')");
     if (@
    mysql_query($sql)) {
        echo(
    "<p>New Link added</p>");
      } else {
        echo(
    "<p>Error adding link: " .
             
    mysql_error() . "</p>");
      }
    ?>
    <p><a href="<?=$PHP_SELF?>" class="link">Add another Link | </a><a href="author.php" class="link">Return 
      to the list of links</a></p>
    <?php
     
    else: //Allow the user to enter a new author
    ?>
    <form action="<?=$php_self?>" method="post" enctype="multipart/form-data">
      <p><span class="text5">Enter new Link:</span><br />
        <span class="text4">Name:</span> 
        <input type="text" name="name" size="20" maxlength="255" /><br />
        <span class="text4">Email:</span> 
        <input type="text" name="email" size="20" maxlength="255" /><br />
        <span class="text4">_Url_ :</span> 
        <input type="text" name="url" size="20" maxlength="400" /><br />
     <input type="hidden" name="MAX_FILE_SIZE" value="100000">
        <span class="text4"> Send this file: </span> 
        <input name="image" type="file">
    <input type="submit" name="submit" value="SUBMIT" /> </p> 
    </form>
    <?php endif; 
    ?>
    OneX Square Creation
    One man said Why ? ... Another man said Why not ?

  2. #2
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    466
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $image_filename = $time_tmp._.$HTTP_POST_FILES['image']['name'];
    $image_savepath = $HTTP_SERVER_VARS['DOCUMENT_ROOT']."\OneXsquare\lk_image";

    move_uploaded_file($image, $image_savepath);

    looks like you're trying to save it as a directory - add the $image_filename onto the end of $image_savepath

    didn't look much further at the script after noticing it's a windows based one - I always get snags left right and centre with uploads to windows boxes.
    teckis - that's news to me.

  3. #3
    SitePoint Zealot Teraflops's Avatar
    Join Date
    Apr 2002
    Location
    NYC
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pootergeist
    $image_filename = $time_tmp._.$HTTP_POST_FILES['image']['name'];
    $image_savepath = $HTTP_SERVER_VARS['DOCUMENT_ROOT']."\OneXsquare\lk_image";

    move_uploaded_file($image, $image_savepath);

    looks like you're trying to save it as a directory - add the $image_filename onto the end of $image_savepath

    didn't look much further at the script after noticing it's a windows based one - I always get snags left right and centre with uploads to windows boxes.
    Well I did what you said, but the results was not successfull.

    Here is the error messages:

    ___________________________________________

    Warning: Wrong parameter count for move_uploaded_file() in E:\Inetpub\wwwroot\OneXsquare\controlone\admin\Link_files\newlink.php on line 50

    New Link added
    _________________________________________________


    line 50 is where you told me to add $image_filename.
    OneX Square Creation
    One man said Why ? ... Another man said Why not ?

  4. #4
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    466
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    add as in concatenate it onto the path string - that'll be with a dot/period and not a comma

    move_uploaded_file($image, $image_savepath.$image_filename); // <-- spot the dot
    teckis - that's news to me.

  5. #5
    SitePoint Zealot Teraflops's Avatar
    Join Date
    Apr 2002
    Location
    NYC
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That got rid of the problem with line 50, however the script is still not doing what it suppose to do.

    it added a name into mysql table called "C:WINDOWSTEMPphp14.tmp"
    It using the temp name now, and still not placing any file into the folder.

    Any other suggestion ?
    Last edited by Teraflops; Mar 25, 2003 at 17:00.
    OneX Square Creation
    One man said Why ? ... Another man said Why not ?

  6. #6
    SitePoint Zealot Teraflops's Avatar
    Join Date
    Apr 2002
    Location
    NYC
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got it to work !

    Thanks for the help
    Last edited by Teraflops; Mar 28, 2003 at 08:54.
    OneX Square Creation
    One man said Why ? ... Another man said Why not ?


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
  •