Jump to content

Odd upload file script issue...


iPixel

Recommended Posts

So I've got an upload file script...

 

The Form :

<form enctype="multipart/form-data" action="admin.php" method="post">
            <input type="hidden" name="task" id="task" value="salesjournal" />
            <input type="hidden" name="job" id="job" value="uploadfile" />
            Choose a file to upload: <input type="file" name="thefile" />
            <input type="submit" value="UPLOAD" style="height:20px; color:#993333;" />
</form> 

 

The PhP Script:

<?php
$target_dir = "SalesJournal/";

// Add the original filename to our target path.  
//Result is "uploads/filename.extension"
$target_path = $target_dir . basename( $_FILES['thefile']['name']); 

if(move_uploaded_file($_FILES['thefile']['tmp_name'], $target_path)) 
{
	echo "The file ".  basename( $_FILES['thefile']['name']). " has been uploaded to the SalesJournal/ folder.";
}
lse
{
        	                echo "There was an error uploading the file, please try again!";
}
?>

 

This upload the file fine, but once the file is on the server it becomes nearly UN-DELETABLE.

It gets created in a way where i cannot delete or replace the file via ftp, but must go directly to the server and deleted from the server box itself.

 

Any idea what might be causing this? All files and folders are set to full permissions.

Link to comment
https://forums.phpfreaks.com/topic/189430-odd-upload-file-script-issue/
Share on other sites

Spaces in file names are always going to be a problem on unix servers.

So before you define your target path I would do this.

 

$newfilename = str_replace(' ','_',$_FILES['thefile']['name']);

then your setting of $target_path would use $newfilename

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.