Jump to content

[SOLVED] Creating folder and uploading image to host


sniperscope

Recommended Posts

Hi

i am currently using a script which let me create a folder but when i check it via ftp, the script create folder with Nobody owner. So i can not change the permission to upload image.

 

Here is my create folder script

 

<?php
  
  $file_name = $_POST['create_folder'];

if(is_dir($_POST['create_folder'])){
	echo "This file already created.";
	exit;
} else {
	mkdir("../img/stuff/".$_POST['create_folder']);
	//echo "File created...";
}
header('location: admin_panel.php');

?> 

 

and this part of script is uploading image into created directory.

 

<?php
$stuff_name = $_POST['stuff_name'];
   // Configuration - File type Options
      $allowed_filetypes = array('.jpg','.gif','.png'); 
      $max_filesize = 524288;
      $upload_path = 'img/stuff/'.$stuff_name;
	  $upload_path = $upload_path.'/';

   $filename = $_FILES['userfile']['name'];
   $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);

   if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
      die('The file you attempted to upload is too large.');

   if(!is_writable($upload_path))
      die('You cannot upload to the specified directory, please CHMOD it to 777.'); // Here is where the error occur.

   if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
      else
         echo 'There was an error during the file upload.  Please try again.';

?>

 

Any help or idea will be great appreciate.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.