Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Member KillaTeddyX's Avatar
    Join Date
    Dec 2006
    Posts
    81
    Member #
    14455
    Hi everyone back again hopefully to get some help I am currently working on an idea of doing a sort of "gallery" site where vistors can upload their pictures of where they have been on holiday, beautiful scenery they have seen, artistic works etc. But I am having issues here is the error message I am getting when I test the script.
    Error message below

    Warning
    : rename(19b.jpg,C:\Documents and Settings\My Documents\My Pictures6.jpg) [function.rename]: No such file or directory in C:\Program Files\xampp\htdocs\samp\check_image.php on line 42.

    The code.
    PHP Code:
    //Usual connection and sql database connection here

    //Make variables available
    $img_caption $_POST['image_caption'];
    $img_user $_POST['image_username'];
    $img_tmpname $_FILES['image_filename']['name'];
    $today date("Y-m-d");

    //get info on the image being uploaded
    $ImageDir "C:\Documents and Settings\My Documents\My Pictures";
    $ImageName $img_dir $img_tmpname;

    if (
    move_uploaded_file($_FILES['image_filename']['tmp_name'], $ImageName)){
    list(
    $width$height$type$attr) = getimagesize($ImageName);

    switch (
    $type) {
    case 
    1:
    $ext ".gif";
    break;
    case 
    2:
    $ext ".jpg";
    break;
    case 
    3:
    $ext ".png";
    break;
    default:
    echo 
    "Sorry you are trying to upload an invalid file extension<br />";
    echo 
    "Please press the browsers back button to try again. Thanks";
    }
    //Insert the data into images table
    $insert "INSERT INTO images
    (image_caption, image_username, image_date)
    VALUES
    ('
    $img_caption', '$img_user', '$today')";
    $insertresult mysql_query($insert)
    or die (
    "Invalid Query: " .mysql_error());

    $lastpicid mysql_insert_id();

    $newfilename $ImageDir $lastpicid $ext//line42

    rename($ImageName$newfilename); 
    }
    ?>
    <!--Begin HTML--> 
    Please help??

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    Unless you have your own server on your own PC, this line:

    $ImageDir = "C:\Documents and Settings\My Documents\My Pictures";

    is referencing your PC, not directories on the internet.

    I think you need to explain some more about where your site is located,
    on what webhost, and your level of PHP/MySQL knowledge.


  4. #3
    Member KillaTeddyX's Avatar
    Join Date
    Dec 2006
    Posts
    81
    Member #
    14455
    Hi Mlseim, the website isn't located on the web at the moment as I am testing it out using the localhost (apache). Firstly and I think most importantly to make sure that everything works cool before I start logging up the internet with a non working web site. I am fairly new to Mysql and php so my knowledge isn't so great as I am still learning things from the many books on php & mysql I have got. Also the line you refrenced to I changed it to for example
    PHP Code:
    $ImangeDir "C::\Program Files\www" 
    This for example is where I have to store my localhost php scripts if I want to be able to see them I still got error message after changing that.
    error message below
    Warning: rename(19b.jpg,C:\Program Files\www\samp8.jpg) [function.rename]: Invalid argument in C:\Program Files\www\samp\check_image.php on line 44

  5. #4
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    I think the problem is to do with the way you call the rename() function.

    In $newname you have the path to the folder where 19b.jpg resides

    However you will need the full path to the folder in $oldname

    So your function call would look something like

    PHP Code:
    rename("C:\Program Files\www\19b.jpg""C:\Program Files\www\samp8.jpg"); 
    Or try putting 19b.jpg in the folder with this php file, so you can omit the path.

  6. #5
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    I believe that filesystems should use relative URLs to the PHP file trying to control them.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  7. #6
    Member KillaTeddyX's Avatar
    Join Date
    Dec 2006
    Posts
    81
    Member #
    14455
    Steax thanks you were right the filesystems need to be relative not absolute thanks again.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:09 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com