retrieving the file upload name

bunglebrown

New Member
Messages
157
Reaction score
0
Points
0
I have a upload feature run through an actionscript interface. It runs the following php script:

PHP:
<?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?
 

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
Couldn't you just use: basename( $_FILES[ 'Filedata' ][ 'name' ] ); ?
 

bunglebrown

New Member
Messages
157
Reaction score
0
Points
0
I've tried that and it doesn't seem to be working. Anyone with any experience of this?
 

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
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:
<?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:

bunglebrown

New Member
Messages
157
Reaction score
0
Points
0
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.
 

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
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:
Top