nvee Posted November 16, 2009 Share Posted November 16, 2009 Hey guys. This is not that much a code help, but I am fairly new with PHP and have never done a image upload script yet. I notice online that the majority of tutorials shows you how to upload images to a database. I want to upload the file, generate a random new name for the file and write that to a database. I have not worked that much with file() yet, so does anyone know of a fairly simple tutorial (or even assistance here) on how to do this. I have already created the form which writes to the database. It has a file field whose id is img. Link to comment https://forums.phpfreaks.com/topic/181716-image-to-folder-then-entry-in-database/ Share on other sites More sharing options...
Vebut Posted November 16, 2009 Share Posted November 16, 2009 You can use the move_uploaded_file to save the uploaded file to a specific directory. <?php $file = $_FILES['my_file_field']['tmp_name']; $destination = 'uploaded/files/'; $filename = 'new_image_upload.jpg'; if (move_uploaded_file($file, $destination.$filename)) { echo "File has been uploaded"; } else echo "File could not be uploaded, check destination permissions."; ?> Link to comment https://forums.phpfreaks.com/topic/181716-image-to-folder-then-entry-in-database/#findComment-958403 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.