client/Topic(anything,href[])
if("Upload" in href)
var/mob/permitted/A=src.mob
if(!A.managing)
A.Manage_Files()
return
if(A.fileUpload)
A.Manage_Files()
return
A.fileUpload=1
var/list/T = list(".dmb",".rsc",".sav")
var/F = input("Select a file to upload.") as null|file
if(!F)
A.fileUpload=0
return
var/f="[F]"
var/Spot=findtext(f,".")
if(!Spot)
src<<"System could not detect file type in [f] or [F]." //Debugging line I added.
A.fileUpload=0
return
var/Path="Servers/[href["Upload"]]/[f]"
var/Ftype=copytext(f,Spot,length(f)+1)
if(Ftype==".zip")
src << "Disabled until fully functional."
return
if(!fcopy(F,Path))
src << "[f] failed to upload."
A.Auto_Manage_Files("[href["Upload"]]")
A.fileUpload=0
return
else
src << "[f] was uploaded successfully."
src << "Unzipping..."
shell("unzip '[Path]' -d 'Servers/[href["Upload"]]'")
src << "Deleting .zip file and all file types not in the allowed list..."
fdel(F)
A.ZipFileCheck("Servers/[href["Upload"]]/",T)
src << "Success!"
A.Auto_Manage_Files("[href["Upload"]]")
A.fileUpload=0
return
if(Ftype in T)
if(!fcopy(F,Path))
src << "[f] failed to upload."
A.Auto_Manage_Files("[href["Upload"]]")
A.fileUpload=0
return
else
src << "[f] was uploaded successfully."
A.Auto_Manage_Files("[href["Upload"]]")
A.fileUpload=0
return
else
src << "Invalid file type."
A.fileUpload=0
return
As I was testing out this code, I saw that when I uploaded a 0KB file (Empty) it did something strange. Instead of temporarily saving var/F, it instead kept the same thing. So, if I were to upload a 0KB "Testing" file, which would say "System could not detect.." in this case, and then upload a 0KB "Testing.dmb" file it would still be on "Testing". I guess if the two files match then it keeps their names the same. Sort of like saving memory and CPU.