SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2007
    0 Post(s)
    0 Thread(s)

    Help modifying upload script destination

    I'm using this upload script, and am wondering if it can be modified to change the destination of the uploaded file.

    Currently I can only upload to a local folder, is it possible to changev this so I can upload to another directory at another url? If os how/where?

    Thanks. Here's part of the code:

    	// Begin options
    	$allow_file_deletion = true; // To allow visitors to delete files, leave this at true; otherwise, change it to false
    	$file_extensions = array(".doc"); // Add or delete the file extensions you want to allow
    	$file_extensions_list = "doc"; // Type the same as above, without the quotes separating them
    	$max_length = 50; // The maximum character length for a file name
    	$maximum_file_size = "2048000"; // In bytes
    	$upload_log_file = "upload_log.txt"; // Change this to the log file you want to use
    	// End options
    	$folder_directory = "http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"]);
    	$message = "";
    	$set_chmod = 0;
    	$site_uri = "http://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"];
    	$upload_directory = "C:/local folder/";
    	$upload_uri = $folder_directory."C:/local folder/";
    	if($allow_file_deletion == true) $status = "enabled";
    	else $status = "disabled";
    	if($_REQUEST["delete"] && $allow_file_deletion) {
    	$resource = fopen($upload_log_file,"a");
    	fwrite($resource,date("F d, Y / h:i:sa")." - ".$_REQUEST["delete"]." deleted by ".$_SERVER["REMOTE_ADDR"]."\n");
    	if(strpos($_REQUEST["delete"],"/.") > 0);
    	elseif(strpos($_REQUEST["delete"],$upload_directory) === false);
    	elseif(substr($_REQUEST["delete"],0,6) == $upload_directory) {
    	$message = "File has been deleted.";
    	header("Location: $site_uri?message=$message");
    	elseif($_FILES["userfile"]) {
    	$resource = fopen($upload_log_file,"a");

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Philadephia, PA
    1 Post(s)
    0 Thread(s)
    Let's say you click the start button on your PC, browse through the start menu and choose Paint. You draw a picture, and want to save it. You click File > Save. You want the image to be saved at "another directory at another url". You type a URL in the filename box.

    It doesn't work. You can't write to a URL.

    You can put the file somewhere else on the same system by changing your "c:/local folder" to that other path. But remember to change whatever script uses these uploaded files to look for them in that new location instead.


Posting Permissions

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