Google dot what?
Posts: 2
16 credits Members referred : 0
« on: Oct 26, 2006, 12:41:35 AM »
I am using your the easy upload php and I am trying to rename the file to var assigned in url querystring. The value will always be included from the referrer where I am using it.
When I set the var manually in the upload page, it works and carries into the class ( $my_upload->DealerID = 1234]; ) but as soon as I try it with the stringqueried var, it does not.
Here is the area that I modified for the new DB upload php. --------------------------------------------------------------------------------------- <?php include ($_SERVER['DOCUMENT_ROOT']."/classes/upload/upload_class.php"); //classes is the map where the class file is stored (one above the root) $max_size = 1024*250; // the max. size for uploading $my_upload = new file_upload;
$my_upload->upload_dir = $_SERVER['DOCUMENT_ROOT']."/files/new/"; // "files" is the folder for the uploaded files (you have to create this folder) $my_upload->extensions = array(".png", ".zip", ".pdf", ".jpg"); // specify the allowed extensions here // $my_upload->extensions = "de"; // use this to switch the messages into an other language (translate first!!!) $my_upload->max_length_filename = 50; // change this value to fit your field length in your database (standard 100) $my_upload->rename_file = true;
if (isset($_GET['DealerID'])) { // The var is set, so lets process // enter your code here
$my_upload->DealerID = $_GET['DealerID'];
// etc, etc }
Here is the area from the class php that should rename the file to DealerID but it only names it to .jpg As you can see, all I did was substitue DealerID for name in the rename function. ----------------------------------------------------------------------------------------------------------------------------------------------------
class file_upload { var $DealerID; var $the_file; var $the_temp_file; var $upload_dir; var $replace; var $do_filename_check; var $max_length_filename = 100; var $extensions; var $ext_string; var $language; var $http_error; var $rename_file; // if this var is true the file copy get a new name var $file_copy; // the new name var $message = array(); var $create_directory = true;
function file_upload() { $this->language = "en"; // choice of en, nl, es $this->rename_file = true; $this->ext_string = ""; } function show_error_string() { $msg_string = ""; foreach ($this->message as $value) { $msg_string .= $value."<br />\n"; } return $msg_string; } function set_file_name($new_name = "") { // this "conversion" is used for unique/new filenames if ($this->rename_file) { if ($this->the_file == "") return; $name = ($new_name == "") ? strtotime("now") : $new_name; sleep(3); $name = $this->DealerID.$this->get_extension($this->the_file); } else { $name = str_replace(" ", "_", $this->the_file); // space will result in problems on linux systems } return $name; }
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6440
39464 credits Members referred : 374
It's time to use PHP5!
« Reply #1 on: Oct 26, 2006, 01:01:22 AM »
check the code inside this example file: "upload_example.php" there is explained how to rename the file
Google dot what?
Posts: 2
16 credits Members referred : 0
« Reply #2 on: Oct 26, 2006, 03:20:22 AM »
OK, I have used part of the "upload_example.php" and in that example the user enters the new name in the form, If I pull the var "DealerID" out of the query string...
$test = $_GET['DealerID'];// this is the value sent in from url and will always exist with value from the referring page.
how would I use $test as the new name and eleminate the need for the new name entry. I am not able to simple replace the name var with $test because the settings will use the time stamp.
I tried replacing ['name'] with ['test'] $new_name = (isset($_POST['name'])) ? $_POST['name'] : "";
PLease advise.
David
Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6440
39464 credits Members referred : 374