Jump to content

Recommended Posts

I'm working on an Upload Handler that will upload images to a user's folder.  Right now I'm having troubles with mkdir if the user folder is not already created or just creating the file in the folder if it is already created....

 

I keep getting parse errors on line 28: constant encapsed strings or t-strings, depending on how I try to fix it. I'm trying to act like I know what I'm doing. How's it look so far?

 

(line 28 starts with the mkdir command.)

 

You can try the code yourself at

www.christiancountyvideo.com/loginhomemade/login.php

 

<?php 
session_start(); 
   //---------------------------------------------- 
   //   upload file handler script 
   //---------------------------------------------- 

   // 
   //   specify file parameter name 
   $file_param_name = 'file'; 

   // 
   //   retrieve uploaded file name 
   $file_name = $_FILES[ $file_param_name ][ 'name' ]; 

   // 
   //   retrieve uploaded file path (temporary stored by php engine) 
   $source_file_path = $_FILES[ $file_param_name ][ 'tmp_name' ]; 

   // 
   //   construct target file path (desired location of uploaded file) - 
   //   here we put to the web server document root (i.e. '/home/wwwroot') 
   //   using user supplied file name 


if (file_exists("c:\\Server\\upload\\" . $_SESSION['usuario'])) { 
   $target_file_path = "c:\\Server\\upload\\" . $_SESSION['usuario'] . "\\" . $file_name; 
} else { 
mkdir "c:\\Server\\upload\\" . $_SESSION['usuario']; 
} 

$target_file_path = "c:\\Server\\upload\\" . $_SESSION['usuario'] . "\\" . $file_name; 

// 
   //   move uploaded file 
   echo "Moving file " . $source_file_path . " > " . $target_file_path . ": "; 
   if( move_uploaded_file( $source_file_path, $target_file_path ) ) { 
      echo "success"; 
   } else{ 
      echo "failure"; 
   } 

   // 
   //   below is trace of variables 
?> 
<html> 
<body> 
   <h1>GET content</h1> 
   <pre><?print_r( $_GET );?></pre> 
   <h1>POST content</h1> 
   <pre><?print_r( $_POST );?></pre> 
   <h1>FILES content</h1> 
   <pre><?print_r( $_FILES );?></pre> 
</body> 

 

 

 

Thanks for the help!!!

benrussell

_________________

I can do this!

Link to comment
https://forums.phpfreaks.com/topic/42360-upload-handler-hell/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.