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.

Link to comment
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.