iPixel Posted January 22, 2010 Share Posted January 22, 2010 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 More sharing options...
iPixel Posted January 22, 2010 Author Share Posted January 22, 2010 So I spoke to an IT guy who managed to delete the file via FTP. He said i'd need to put quotes around the filename because this happens if the filename has spaces in it. But i dont see a way to do that with the script and still make it work. Link to comment https://forums.phpfreaks.com/topic/189430-odd-upload-file-script-issue/#findComment-999922 Share on other sites More sharing options...
jl5501 Posted January 22, 2010 Share Posted January 22, 2010 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 Link to comment https://forums.phpfreaks.com/topic/189430-odd-upload-file-script-issue/#findComment-1000171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.