Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    extremely urgent upload help needed

    hi guys

    ok below is my code for the page that processes the file upload

    PHP Code:
    $target_path "../cvstorage/";
    /* Add the original filename to our target path.  
    Result is "uploads/filename.extension" */
    $target_path $target_path basename$_FILES['uploadedfile']['name']); 
    $_FILES['uploadedfile']['tmp_name'];  
    if(
    move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    $cvid $_GET['cvid'];
    $jobseekerid $_GET['jobseekerid'];
    $cvlocation $_FILES['uploadedfile']['name'];
    $keywords $_GET['keywords'];
    mysql_select_db($dbn$dbc);
    $upload mysql_query("INSERT INTO `cvstorage` (`cvid`,`jobseekerid`,`cvlocation`,`keywords`) VALUES ($cvid,$jobseekerid,'http://www.domain.com/cvstorage/$cvlocation',$keywords)"$dbc);

    nothing at all happens

    im trying to upload a file to the cvstorage folder and then insert the data into the db

    please help guys

    the site goes live very soon

    thanks in advance
    Last edited by managedinternet; 08-31-2006 at 02:16 AM.

  • #2
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry, is there a reason you have:

    PHP Code:
    $upload mysql_query("INSERT INTO `cvstorage` (`cvid`,`jobseekerid`,`cvlocation`,`keywords`) VALUES ($cvid,$jobseekerid,'http://www.domain.com/cvstorage/$cvlocation',$keywords)"$dbc); 
    instead of:

    PHP Code:
    mysql_query("INSERT INTO `cvstorage` (`cvid`,`jobseekerid`,`cvlocation`,`keywords`) VALUES ($cvid,$jobseekerid,'http://www.domain.com/cvstorage/$cvlocation',$keywords)"$dbc); 
    about the rest -- i'm not sure about syntax. could use a little simplification maybe?

  • #3
    New Coder
    Join Date
    Aug 2006
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    just copied the query from another page and modified it,

    your right though $upload isnt needed


    anyone else offer any help, reaching the deadline before the site is going to launch as we have already spend money advertising the 1st as our luanch

    thanks

  • #4
    New Coder
    Join Date
    Aug 2006
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    here is teh redone code
    still problem happens .. no file uploaded

    please , please help guys

    PHP Code:
    $target_path "http://www.mydomainco.uk/cvstorage/";

    /* Add the original filename to our target path.  
    Result is "uploads/filename.extension" */
    $target_file $target_path basename$_FILES['uploadedfile']['name']); 
    $_FILES['uploadedfile']['tmp_name'];  
    move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path); 
    here is the debugging info

    Array ( [file] => Array ( [name] => replicant.ttf [type] => application/octet-stream [tmp_name] => /tmp/php18wJVy [error] => 0 [size] => 42388 ) )

  • #5
    New Coder
    Join Date
    Aug 2006
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone have any ideas at all ?

    its very urgent

  • #6
    New Coder
    Join Date
    Aug 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Here...

    Here's a working upload script:

    Code:
    <?php
    
    if($image_1)
    {
    	$dir = "media/";
    	copy($image_1, "$dir"."$image_1_name");
    	$image_1 = "$dir"."$image_1_name";
    	echo "File uploaded: $image_1<br>";
    
    //write image name to text file:
    	
    	
    	$start = "<img src = ";
    	$finish = "><br>";
    
    
    	$fileopen = fopen("images.htm", "a");  //a stands for append
    	fputs($fileopen, "$start"); //adds the file name to the open file
    	fputs($fileopen, "$image_1");
    	fputs($fileopen, "$finish\n");
    	fclose($fileopen);
    };
    
    echo "<form method=\"post\" action=\"upload.php\"enctype=\"multipart/form-data\">";
    
    echo "Upload Image: <input type=file name=\"image_1\"><br>";
    
    echo "<input type=\"submit\" name=\"upload\" value=\"Add Image\"><p>";
    
    echo "</form>";
    
    ?>
    This code assumes that this file is uploaded to the server and the appropriate file and directory permissions have been set.

  • #7
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    I think the original code will work if the form uses post rather than get.
    I set up:
    PHP Code:
    <?php
    if(count($_POST)>0) {
        
    $target_path "../cvstorage/"
        
    /* Add the original filename to our target path.   
        Result is "uploads/filename.extension" */ 
        
    $target_path $target_path basename$_FILES['uploadedfile']['name']);  
        
    $_FILES['uploadedfile']['tmp_name'];   
        if(
    move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { 
            
    $cvid $_POST['cvid']; 
            
    $jobseekerid $_POST['jobseekerid']; 
            
    $cvlocation $_FILES['uploadedfile']['name']; 
            
    $keywords $_POST['keywords']; 
            echo 
    "INSERT INTO `cvstorage` (`cvid`,`jobseekerid`,`cvlocation`,`keywords`) VALUES ($cvid,$jobseekerid,'http://www.domain.com/cvstorage/$cvlocation','$keywords')";
        } 
    }
    ?>

    <form action="" enctype="multipart/form-data" method="post">
    <input type="file" name="uploadedfile" />
    <input type="text" name="jobseekerid" value="12" />
    <input type="text" name="keywords" value="some keywords" />
    <input type="text" name="cvid" value="7" />
    <input type="submit" value="go" />
    </form>
    and it works fine (I echo the query as I don't have mysql installed, the only change being 's around the keywords)

  • #8
    New Coder
    Join Date
    Aug 2006
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi,

    thanks guys,

    i used GJays ( the same i had )
    and it still isnt uploading to the dir or writing to the db

    the folder permissions are 777 so im really puzzled

  • #9
    New Coder
    Join Date
    Aug 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Try mine...

    ...so the script I posted doesn't work either or are you so caught up with your own code that you can't bother to try someone elses?

  • #10
    New Coder
    Join Date
    Aug 2006
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    used GJays because i dont understand what i would need to modify in your code, never been too good with fputs etc

  • #11
    New Coder
    Join Date
    Aug 2006
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    guys i fixed it

    script was fine ,

    i just put the relative path in for teh upload folder ie /home/myuser/public_html/cvstorage/

    works fine

    thanks to all for thier help

  • #12
    New Coder
    Join Date
    Aug 2006
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    1 thing though.. if the file already exists how do i get it to overwrite the original ?

  • #13
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    PHP Code:
    $file '';
    if (
    file_exists($file)){
        
    unlink($file);


  • #14
    New Coder
    Join Date
    Aug 2006
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks,

    also its not writing to the db

    file upload fine though

  • #15
    New Coder
    Join Date
    Aug 2006
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts
    totally bamboozled

    my original script is working however the info is not getting written to the db


    ideas anyone ?


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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