22, November 2008

Easy upload php - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Easy PHP Upload (Moderator: Olaf)
Topic: Easy upload php
« previous next »
Pages: [1] Print

Author Topic: Easy upload php  (Read 1253 times)
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: Male
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


Last blog : Just a better Internet portal provided by Google
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: Male
Posts: 6440
39464 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Oct 26, 2006, 09:20:59 AM »

$new_name = (isset($_GET['DealerID'])) ? $_GET['DealerID'] : "";

place an echo in front of it to see that variable is filled otherwise put the dealer ID into a hidden formfield


Last blog : Just a better Internet portal provided by Google
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=4562
Tags : php databases linux Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Easy PHP Upload (Moderator: Olaf)
Topic: Easy upload php
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Nov 22, 2008, 02:41:56 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 37.736
Total Topics: 7.650
Total Members: 4.396
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: thomas09

28 Guests, 4 Users online :

11 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.