My vBulletin 4 forum returned error when i tried to insert image into my post from URL selecting option to "retrieve remote file and reference locally".
Result: error: Upload failed due to failure writing temporary file

After researching error on search engine i found the solution:

Go to vBulletin administrator area > Options > Server Settings and Optimization Options
there find option "Safe Mode Upload Enabled" and set to YES

retry the image upload. If it continue failing, find option "Safe Mode Temporary Directory" on same page and set it to appropriate path (example /home/yourusernamehere/tmp , /home/user/public_html/domain.tld/tmp ...) . Correct path you may guess when you go to vBulletin AdminCP > Maintenance > View PHP info > and search for "DOCUMENT_ROOT".

Create new directory "tmp" or similar named (preferably original named so the bots do not find it) in your web root folder and set this directory permissions to be execute, read and write by everyone (777).