diff --git a/README.md b/README.md
index f03674b7335e031e86bd5fd871ad9bb5393e5648..643b528b045b800d991933e42385d242c2456fb1 100644
--- a/README.md
+++ b/README.md
@@ -36,7 +36,7 @@ The install and uninstall scripts are very simple, I'll briefly outline what the
 
 Eventually I'll add this to the official KDE store thing so it's just a matter of clicking install and configuring it.
 
-## Configuration
+## Required Configuration
 
 Go to `~/.local/share/kservices5/srvrupload/` and open `srvrupload.sh` in your preferred text editor.
 
@@ -48,10 +48,10 @@ I have briefly described the meaning of each variable in the comments above them
 
 ## Known issues
 
-* Issues to do with files with spaces in their names.
+* Anything to do with special characters in the file name. (I don't yet know how to counter anything other than spaces)
 
 ## Info
 
-Thanks to [Jamesjon](https://www.pling.com/u/jamesjon/) for his many many Dolphin Service Menus I could follow through to learn how to write this one. for his many many scripts I could follow through to learn how to write this one.
+Thanks to [Jamesjon](https://www.pling.com/u/jamesjon/) for his many many Dolphin Service Menus I could follow through to learn how to write this one.
 
 Thanks to [Nevalain](https://store.kde.org/u/nevalain) for making a similar script in 2005 (Probably for KDE 3.4) which gave me the idea.
diff --git a/srvrupload.sh b/srvrupload.sh
index ce2610d10f04442fa631906bee6f37e400df9693..1944749314d8c5bbc17a6f0f5362a7619a103267 100755
--- a/srvrupload.sh
+++ b/srvrupload.sh
@@ -17,21 +17,35 @@ remote_path=/var/www/public/
 # The URL (excluding file name) you expect the file to have to be accessible
 expectedURL="https://yourserver.com/public/"
 
-# Path to the file to be uploaded
+# The file path as passed through by KDE (The file you clicked "Upload to server" on)
 local_path=$1
 
-# Name of the file to be uploaded
-fileName=$(basename $local_path)
+# The name of the file itself, without path
+fileName=$(basename "$local_path")
 
-# Generates a random number to be prepended to the file name
+# A string of random numbers to be prepended to the file name
 randomString=$(shuf -i 100000000000-999999999999 -n 1)
 
-cp $local_path /tmp/$fileName
-mv /tmp/$fileName /tmp/$randomString$fileName
-local_path=/tmp/$randomString$fileName
+# Copy the file to tmp folder
+cp "$local_path" "/tmp/$fileName"
 
-# Uploading the file
-sshpass -p $serverPassword scp -P $serverPort $local_path $serverUsername@$serverURL:$remote_path
-link=$expectedURL$randomString$fileName
+# Replace any spaces in the file name with an underscore
+cleanFileName=${fileName// /_}
+
+# Rename the file to the new name created above
+mv "/tmp/$fileName" "/tmp/$randomString$cleanFileName"
+
+# Reassign the local path variable to be the full new path of the file
+local_path="/tmp/$randomString$cleanFileName"
+
+# Upload the file to the server
+sshpass -p $serverPassword scp -P $serverPort "$local_path" $serverUsername@$serverURL:"$remote_path"
+
+# Generate a link to the file based on the variables specified at the start of this file.
+link="$expectedURL$randomString$cleanFileName"
+
+# Copy the link to xclip
 echo $link | xclip
+
+# Notify the user that the file has been uploaded and show the link
 notify-send --app-name="Server Upload" --icon="cloud-upload" "Link copied to xclip $link" --expire-time=5000 > /dev/null 2>&1