+ Reply to Thread
Results 1 to 6 of 6

Thread: retrieving the file upload name

  1. #1
    bunglebrown is offline x10 Sophmore bunglebrown is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    157

    Question retrieving the file upload name

    I have a upload feature run through an actionscript interface. It runs the following php script:

    PHP Code:
    <?PHP

    $target_path 
    $_REQUEST'path' ];

    $target_path $target_path basename$_FILES'Filedata' ][ 'name' ] ); 



    if ( 
    move_uploaded_file$_FILES'Filedata' ][ 'tmp_name' ], $target_path ) ) 

    {

         echo 
    "The file " basename$_FILES'Filedata' ][ 'name' ] ) . " has been uploaded;";



    else

    {

         echo 
    "There was an error uploading the file, please try again!";

    }

    ?>
    During the session the user inputs various pieces of information which are fed to a database, I would like also to feed the name of the uploaded file to the database - anyone any idea how to do that?

  2. #2
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: retrieving the file upload name

    Couldn't you just use: basename( $_FILES[ 'Filedata' ][ 'name' ] ); ?
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


  3. #3
    bunglebrown is offline x10 Sophmore bunglebrown is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    157

    Re: retrieving the file upload name

    I've tried that and it doesn't seem to be working. Anyone with any experience of this?

  4. #4
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: retrieving the file upload name

    Are you saying the script doesn't work at all? It's pretty easy to upload a file. Notice that each will output the attribute of the file. Alll you need is $_FILES["file"]["name"]

    PHP Code:
    <?php
    if ($_FILES["file"]["error"] > 0)
      {
      echo 
    "Error: " $_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 
    "Stored in: " $_FILES["file"]["tmp_name"];
      }
    ?>
    Last edited by vol7ron; 12-15-2008 at 09:57 PM.
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


  5. #5
    bunglebrown is offline x10 Sophmore bunglebrown is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    157

    Re: retrieving the file upload name

    no I'm not saying that it doesn't upload, only that I'm not able to retrieve the filename of the uploaded file and for example put it in a database so that I know which user has uploaded which file.

  6. #6
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: retrieving the file upload name

    well apply the subscript i showed you to your code to see if any of that outputs. i was trying to show you how to retrieve it and if it worked all in one step.
    Last edited by vol7ron; 12-16-2008 at 06:23 PM.
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


+ Reply to Thread

Similar Threads

  1. file upload script
    By nightscream in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 01-11-2011, 05:04 PM
  2. Replies: 2
    Last Post: 11-01-2008, 09:48 PM
  3. configuring php on localhost
    By ufclan in forum Scripts & 3rd Party Apps
    Replies: 15
    Last Post: 01-22-2008, 08:34 AM
  4. File upload Limit
    By Team Dread in forum Free Hosting
    Replies: 1
    Last Post: 01-21-2008, 03:12 PM
  5. [PHP] Creating a File Upload Script
    By o0slowpaul0o in forum Tutorials
    Replies: 17
    Last Post: 10-05-2005, 01:39 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