Closed Thread
Results 1 to 5 of 5

Thread: help in php upload image ,rename for 150 c

  1. #1
    nahsorhseda's Avatar
    nahsorhseda is offline x10 Sophmore nahsorhseda is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    mumbai
    Posts
    116

    help in php upload image ,rename for 150 c

    below i have a script which can be used to upload images ,but the problem is i want the files to be renamed
    for ex:if i have a file called "ab cd.jpg" ,i want to rename it to "ab_cd.jpg" or abcd.jpg i just want the spaces to dissappear .......

    iam learning php and iam testing/working on a image editing script thats why i want the files to be renamed

    here is the script please change it and post ......i mean the whole script from<?php to ?> please dont write half the script n post ....coz iam just a beginner....ill also pay you 100-150 credits for the work

    here is the script....

    PHP Code:
    l;

    <?php
    if (($_FILES["file"]["type"] == "image/gif")
    || (
    $_FILES["file"]["type"] == "image/jpeg")
    || (
    $_FILES["file"]["type"] == "image/png")
    || (
    $_FILES["file"]["type"] == "image/vnd.wap.wbmp")
    || (
    $_FILES["file"]["type"] == "image/bmp")
    || (
    $_FILES["file"]["type"] == "image/pjpeg")
    && (
    $_FILES["file"]["size"] < 200000000000000))
      {
      if (
    $_FILES["file"]["error"] > 0)
        {
        echo 
    "Return Code: " $_FILES["file"]["error"] . "<br />";
        }
      else
        {
        echo 
    "Upload: " $_FILES["file"]["name"] . "<br />";
        echo 
    "Type: " $_FILES["file"]["type"] . "<br />";
        echo 
    "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
        echo 
    "Temp file: " $_FILES["file"]["tmp_name"] . "<br />";
        if (
    file_exists("./" $_FILES["file"]["name"]))
          {
          echo 
    $_FILES["file"]["name"] . " already exists. ";

          }
        else
          {
          
    move_uploaded_file($_FILES["file"]["tmp_name"],
          
    "./" $_FILES["file"]["name"]);
          echo 
    "Stored in: " "image editor/" $_FILES["file"]["name"];
    echo
    "<br/>";


          }
        }
      }
    else
      {
      echo 
    "invalid file<br/>";

      }
    ?>

    thnks in advance
    glad to resolve problems in c++ n php

  2. #2
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: help in php upload image ,rename for 150 c

    PHP Code:


    <?php
    if (($_FILES["file"]["type"] == "image/gif")
    || (
    $_FILES["file"]["type"] == "image/jpeg")
    || (
    $_FILES["file"]["type"] == "image/png")
    || (
    $_FILES["file"]["type"] == "image/vnd.wap.wbmp")
    || (
    $_FILES["file"]["type"] == "image/bmp")
    || (
    $_FILES["file"]["type"] == "image/pjpeg")
    && (
    $_FILES["file"]["size"] < 200000000000000))
      {
      if (
    $_FILES["file"]["error"] > 0)
        {
        echo 
    "Return Code: " $_FILES["file"]["error"] . "<br />";
        }
      else
        {
        echo 
    "Upload: " str_replace(' ','_',$_FILES["file"]["name"]) . "<br />";
        echo 
    "Type: " $_FILES["file"]["type"] . "<br />";
        echo 
    "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
        echo 
    "Temp file: " $_FILES["file"]["tmp_name"] . "<br />";
        if (
    file_exists("./" $_FILES["file"]["name"]))
          {
          echo 
    $_FILES["file"]["name"] . " already exists. ";

          }
        else
          {
          
    move_uploaded_file($_FILES["file"]["tmp_name"],
          
    "./" str_replace(' ','_',$_FILES["file"]["name"]);
          echo 
    "Stored in: " "image editor/" $_FILES["file"]["name"];
    echo
    "<br/>";


          }
        }
      }
    else
      {
      echo 
    "invalid file<br/>";

      }
    ?>

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


  3. #3
    nahsorhseda's Avatar
    nahsorhseda is offline x10 Sophmore nahsorhseda is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    mumbai
    Posts
    116

    Re: help in php upload image ,rename for 150 c

    iam gettimg an error
    Parse error: syntax error, unexpected ';' in /home/hsedan/public_html/monstir/upload.php on line 140
    the line is what u edited
    "./" . str_replace(' ','_',$_FILES["file"]["name"]);
    glad to resolve problems in c++ n php

  4. #4
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: help in php upload image ,rename for 150 c

    PHP Code:
    <?php

    $fn 
    $_FILES["file"]["name"];
    $fn str_replace(" ","_",$fn);
    if ((
    $_FILES["file"]["type"] == "image/gif")
    || (
    $_FILES["file"]["type"] == "image/jpeg")
    || (
    $_FILES["file"]["type"] == "image/png")
    || (
    $_FILES["file"]["type"] == "image/vnd.wap.wbmp")
    || (
    $_FILES["file"]["type"] == "image/bmp")
    || (
    $_FILES["file"]["type"] == "image/pjpeg")
    && (
    $_FILES["file"]["size"] < 200000000000000))
      {
      if (
    $_FILES["file"]["error"] > 0)
        {
        echo 
    "Return Code: " $_FILES["file"]["error"] . "<br />";
        }
      else
        {
        echo 
    "Upload: " $fn "<br />";
        echo 
    "Type: " $_FILES["file"]["type"] . "<br />";
        echo 
    "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
        echo 
    "Temp file: " $_FILES["file"]["tmp_name"] . "<br />";
        if (
    file_exists("./" $fn))
          {
          echo 
    $fn " already exists. ";

          }
        else
          {
          
    move_uploaded_file($_FILES["file"]["tmp_name"],
          
    "./" $fn);
          echo 
    "Stored in: " "image editor/" $fn;
    echo
    "<br/>";


          }
        }
      }
    else
      {
      echo 
    "invalid file<br/>";

      }
    ?>

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


  5. #5
    nahsorhseda's Avatar
    nahsorhseda is offline x10 Sophmore nahsorhseda is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    mumbai
    Posts
    116

    Re: help in php upload image ,rename for 150 c

    actually there was a only a small mistake in your code
    that you forgot to add an ")" to the code
    now the code would be
    "./" . str_replace(' ','_',$_FILES["file"]["name"]));
    u get your 100 c
    glad to resolve problems in c++ n php

Closed Thread

Similar Threads

  1. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM
  2. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 PM
  3. errors while attaching
    By mattspec in forum Feedback and Suggestions
    Replies: 0
    Last Post: 12-19-2005, 01:50 PM
  4. November Desktop
    By n4tec in forum Off Topic
    Replies: 12
    Last Post: 11-08-2005, 07:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers