sniped22 Posted February 26, 2007 Share Posted February 26, 2007 On one page I have a file upload box where the user browses to the proper file, on the other it displays some info about the file. How do I create a new html file implementing the uploaded file. I have it generate a random 10 digit number which I want to become the file's own page. So I generate the number, say 1234567890, how can I make that file in a php script, and then get the filename and use it in an object tag or img tag on 1234567890.html? To make it clearer, I upload a.jpg, a random number 1111111111 is generated. I want the script to generate an html document with something like this: <html> <body> <img src="../upload/a.jpg"> //a.jpg would have to be a variable such as $filename, and php would have to echo it somehow> </body> </html> If any of you are familiar with imageshack.us, this is basically what I'm getting at. Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/40102-solved-upload/ Share on other sites More sharing options...
skali Posted February 26, 2007 Share Posted February 26, 2007 <?php $random = $your_random_number $new_page = "/home/your_content_dir/".$random.".html"; $somecontent = '<html> <body> <img src="../upload/'.$uploaded_file_name.'"> //a.jpg would have to be a variable such as $filename, and php would have to echo it somehow> </body> </html>'; if (!$handle = fopen($new_page, 'w')) { echo "Cannot open file ($new_page)"; exit; } if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($new_page)"; exit; } echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle); } ?> Link to comment https://forums.phpfreaks.com/topic/40102-solved-upload/#findComment-194235 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.